Get by Id
@param int $widgetId Widget ID
@return $this|XiboWidget
@throws XiboApiException
12222
public function getById($widgetId)
    {
        $this->getLogger()->info('Getting widget ID ' . $widgetId);
        $response = $this->doGet('/playlist/widget', [
            'widgetId' => $widgetId
        ]);

        $resonse = clone $this->hydrate($response[0]);
        if ($response[0]['type'] != $this->type)
            throw new XiboApiException('Invalid widget type');

        return $this;
    }
1025696
public function getProspectsDataForWidgets($widgetId = '')
	{
	    
	    $prospectsTable = $this->getServiceLocator()->get('MelisProspects');
	    
	    $dataProspects = $prospectsTable->getProspectsOrderByDate();
	
	    $numPropects = 0;
	    $numPropectsMonth = 0;
	    $numPropectsMonthAvg = 0;
	
	    if (!empty($dataProspects))
	    {
	        $datas = $dataProspects->toArray();
	        if (!empty($datas))
	        {
	            $numPropects = count($datas);
	
	            $curMonthYear = date('m-Y'); // Current Month
	            $sumMonthProspects = 0; // Sum of the Months Prospects
	            $flagFirstDate = TRUE;
	            $firstDate = '';
	
	            for ($i = 0; $i < $numPropects; $i++)
	            {
	                $dataMonthYear = date('m-Y',strtotime($datas[$i]['pros_contact_date'])); // Get Month value from Data
	                if($dataMonthYear == $curMonthYear)
	                {
	                    $numPropectsMonth++;
	                }
	
	                if ($flagFirstDate)
	                {
	                    $firstDate = date('Y-m-d',strtotime($datas[$i]['pros_contact_date']));
	                    $flagFirstDate = FALSE; // Set False After get the First Date of Prospects
	                }
	            }
	
	            $numMonths = 0; // Number of Months
	            if ($numPropects != 0 && $firstDate != '')
	            {
	                // Variable initialization
	                $totalNum = null;
	                $test = null;
	                $flag = TRUE;
	                $currentDate = date('Y-m');
	                $tempDate = date('Y-m',strtotime($firstDate));
	                do {
	                    // check if tempDate still on range
	                    if ($tempDate<=$currentDate){
	                        // checking date is same as firstDate
	                        if(date('Y-m',strtotime($firstDate))==$tempDate){
	                            // getting value of the firstDate
	                            $totalNum += date('d',strtotime($firstDate))/date('t',strtotime($firstDate));
	                        }else{
	                            // checking if tempDate is the last date of the range
	                            if (date('Y-m')==$tempDate){
	                                // getting value of the last date of range
	                                // last date is the current date
	                                $totalNum += date('d')/date('t');
	                            }else{
	                                $totalNum++;
	                            }
	                        }
	                        // Add 1 month to set tempMonth to next month
	                        $tempDate = date('Y-m',strtotime($tempDate.' +1 months'));
	                    }else{
	                        $flag = FALSE;
	                    }
	                }while($flag);
	                //Compute Average Prospects per month
	                $numPropectsMonthAvg = $numPropects/$totalNum;
	            }
	        }
	    }
	
	    // Check and return value requested
	    switch ($widgetId) {
	        case 'numPropects':
	            return number_format($numPropects); // return total number of prospects
	            break;
	        case 'numPropectsMonth':
	            return number_format($numPropectsMonth); // return total number of prospects of the current month
	            break;
	        case 'numPropectsMonthAvg':
	            return number_format($numPropectsMonthAvg,2); // return average of the total number of prospects
	            break;
	        default:
	            return null;
	            break;
	    }
	
	}
1173924
public function getById(int $id)
	{
		return $this->setAuthorizer($this->getModel()->where('id', '=', $id)->first());
	}
119126
public function onceUsingId($id)
    {
        $user = $this->provider->retrieveById($id);

        $this->setUser($user);

        return ($user instanceof UserInterface);
    }
1115011
public function parameters($id, $widget)
    {
        $widget    = Widget::withoutGlobalScope('menu_assignment')->findOrNew($widget);
        $extension = $this->repository->findOrFail($id);
        $formView  = $extension->param('form');

        if (view()->exists($formView)) {
            return view($formView, compact('widget'));
        }

        return view('widgets.partials.none');
    }
101552
public static function getByID($cID, $cvID = 'RECENT')
    {
        $entity = self::getLocaleFromHomePageID($cID);
        if ($entity) {
            $obj = parent::getByID($cID, $cvID);
            $obj->setLocale($entity);

            return $obj;
        }

        return false;
    }
1045370
public function getModuleById($moduleId)
    {
        foreach ($this->getModules() as $module) {
            if ($module->getModuleId() == $moduleId) {
                return $module;
            }
        }

        return null;
    }
181021
public function getNewDataWidget($widgetType, User $user)
    {
        $widget = $this->widgetFactory->createDataWidget($widgetType);
        $widget
            ->setId(uniqid())
            ->setUser($user);

        return $widget;
    }
1344092
public boolean isSingleWidget(String widgetId) {
		try {
			WidgetState state = (WidgetState) storageService.getEntityById(widgetId);
			DashboardState dState = getDashboardState(state);
			if (dState.getColumnCount() > 1) {
				return false;
			}
			if (dState.getWidgetStates().size() > 1) {
				return false;
			}
			return true;
		} catch (NotFoundException e) {
			return false;
		}
	}
591065
public function hasWidget($widget)
    {
        if ($widget instanceof Model) {
            $widget = $widget->id;
        }

        return $this->widgets()->where('widget_id', $widget)->exists();
    }
354922
public function getWidgetUrl($languageId = null, $inAdmin = null, $urlParameters = [])
    {
        $utilsUrl = Registry::getUtilsUrl();
        $widgetUrl = $this->isSsl() ? $this->getSslShopUrl($languageId) : $this->getShopUrl($languageId, $inAdmin);
        $widgetUrl = $utilsUrl->processUrl($widgetUrl . 'widget.php', false);

        if (!isset($languageId)) {
            $language = Registry::getLang();
            $languageId = $language->getBaseLanguage();
        }
        $urlLang = $utilsUrl->getUrlLanguageParameter($languageId);
        $widgetUrl = $utilsUrl->appendUrl($widgetUrl, $urlLang, true);

        $widgetUrl = $utilsUrl->appendUrl($widgetUrl, $urlParameters, true, true);

        return $widgetUrl;
    }
978637
protected function ___attainWidgetInstance($widget)
    {
        /** @var $widgetManager WidgetManager */
        $widgetManager = $this->sm->get('yimaWidgetator.WidgetManager');

        $options = [];
        if (is_array($widget)) {
            $wArg    = $widget;
            $widget  = $wArg['widget'];
            $options = (isset($wArg['params'])) ? $wArg['params'] : $options;
        }

        $instance = $widgetManager->get($widget, $options);

        return $instance;
    }
318786
public function prepareAsynchronousRender($widgetId)
    {
        $ngControllerName = 'widget'.$widgetId.'AsynchronousLoadCtrl';
        $ngDirectives = sprintf('ng-controller="WidgetAsynchronousLoadController as %s" class="vic-widget" ng-init="%s.init(%d)" ng-bind-html="html"', $ngControllerName, $ngControllerName, $widgetId);
        $html = sprintf('<div class="vic-widget-container vic-widget-asynchronous" data-id="%d" %s></div>', $widgetId, $ngDirectives);

        return $html;
    }
687357
protected function _resolveWidget($widget)
    {
        $type = gettype($widget);
        if ($type === 'object') {
            return $widget;
        }

        if ($type === 'string') {
            $widget = [$widget];
        }

        $class = array_shift($widget);
        $className = App::className($class, 'View/Widget', 'Widget');
        if ($className === false || !class_exists($className)) {
            throw new RuntimeException(sprintf('Unable to locate widget class "%s"', $class));
        }
        if ($type === 'array' && count($widget)) {
            $reflection = new ReflectionClass($className);
            $arguments = [$this->_templates];
            foreach ($widget as $requirement) {
                $arguments[] = $this->get($requirement);
            }
            $instance = $reflection->newInstanceArgs($arguments);
        } else {
            $instance = new $className($this->_templates);
        }
        if (!($instance instanceof WidgetInterface)) {
            throw new RuntimeException(sprintf('"%s" does not implement the WidgetInterface', $className));
        }

        return $instance;
    }
254551
public static function getMenu($appid, $pid = 0) {
		$button = static::find()->where(['appid' => $appid, 'conditional' => 0, 'pid' => $pid])->select('id, type, name, key, url, media_id')->orderby('list_order, created_at')->asArray()->all();

		foreach($button as $index => $_button) {
			$button[$index]['sub_button'] = static::getMenu($appid, $_button['id']);
			unset($_button['id']);
		}

		return $button;
	}
1107000
public function getById($id)
    {
        if ($this->id == $id) return $this;

        return $this->children->getById($id);
    }
913884
public function getWidgetQueryBuilder(Widget $widget)
    {
        //get the base query
        $itemsQueryBuilder = $this->queryHelper->getQueryBuilder($widget, $this->entityManager);

        // Filter only visibleOnFront
        $itemsQueryBuilder->andWhere('main_item.visibleOnFront = true');

        //add the query of the widget
        return $this->queryHelper->buildWithSubQuery($widget, $itemsQueryBuilder, $this->entityManager);
    }