@param PortfolioWidget $portfolioWidget
@param bool            $withView

@return array
488176
public function getPortfolioWidgetData(PortfolioWidget $portfolioWidget, $withView = true)
    {
        $widget = $portfolioWidget->getWidget();

        $widgetViews = array(
            'views' => $withView ? array('view' => $this->getView($widget, $widget->getWidgetType())) : array(),
        );

        $widgetData = [
            'widget' => $widget->getCommonData() + $widgetViews + ($withView ? $widget->getData() : $widget->getEmpty()),
        ];

        return  $portfolioWidget->getData() + $widgetData;
    }
402209
public function handleVisibility(Portfolio $portfolio)
    {
        $originalPortfolioUsers = $portfolio->getPortfolioUsers();
        $originalPortfolioGroups = $portfolio->getPortfolioGroups();
        $originalPortfolioTeams = $portfolio->getPortfolioTeams();
        $form = $this->getVisibilityForm($portfolio);

        $request = $this->requestStack->getCurrentRequest();
        if ($request->isMethod('POST')) {
            $form->submit($request);

            if ($form->isValid()) {
                $this->portfolioManager->updateVisibility($portfolio, $originalPortfolioUsers, $originalPortfolioGroups, $originalPortfolioTeams);

                return true;
            }
        }

        return false;
    }
637675
public function toArray(bool $withParentAndChild = true): array
    {
        $array = [
            'name'                  => $this->getName(),
            'shortName'             => $this->getShortName(),
            'configurationRootName' => $this->getConfigurationRootName(),
            'rootNamespace'         => $this->getRootNamespace(),
            'path'                  => $this->getPath(),
            'dataFixtures'          => $this->getDataFixtures()->toArray(),
        ];

        if ($withParentAndChild) {
            if (null !== $this->getParentBundleDescriptor()) {
                $array['parentBundleDescriptor'] = $this->getParentBundleDescriptor()->toArray(false);
            }

            if (null !== $this->getChildBundleDescriptor()) {
                $array['childBundleDescriptor'] = $this->getChildBundleDescriptor()->toArray(false);
            }
        }

        return $array;
    }
61210
protected function extractFormationsWidgets(\SimpleXMLElement $nodes, Portfolio $portfolio)
    {
        $portfolioWidgets = [];
        $formationsWidgetsNodes = $nodes->xpath("//entry[rdf:type/@rdf:resource='leap2:activity' and category/@term='Education']");

        foreach ($formationsWidgetsNodes as $formationsWidgetsNode) {
            $portfolioWidget = $this->widgetsManager->getNewPortfolioWidget($portfolio, 'formations');
            $formationsWidget = new FormationsWidget();
            $portfolioWidget->setWidget($formationsWidget);
            $formationsWidgetTitle = $formationsWidgetsNode->xpath('title');
            $formationsWidget->setUser($portfolio->getUser());
            if (0 === count($formationsWidgetTitle)) {
                throw new \Exception('Entry has no title.');
            }

            $formationWidgetLabel = (string) $formationsWidgetTitle[0];
            $formationsWidget
                ->setLabel($formationWidgetLabel)
                ->setName($formationWidgetLabel);

            $formationsWidgetStartDate = $formationsWidgetsNode->xpath("leap2:date[@leap2:point='start']");

            if (0 < count($formationsWidgetStartDate)) {
                $formationsWidget->setStartDate(new \DateTime((string) $formationsWidgetStartDate[0]));
            }

            $formationsWidgetEndDate = $formationsWidgetsNode->xpath("leap2:date[@leap2:point='end']");

            if (0 < count($formationsWidgetEndDate)) {
                $formationsWidget->setEndDate(new \DateTime((string) $formationsWidgetEndDate[0]));
            }

            $formationsWidgetResources = [];

            foreach ($formationsWidgetsNode->xpath("link[@rel='leap2:has_part']/@href") as $relatedResourceAttributes) {
                $relatedResourceArrayAttributes = (array) $relatedResourceAttributes;
                $relatedResourceNodes = $nodes->xpath(sprintf("entry[id[.='%s']]", $relatedResourceArrayAttributes['@attributes']['href']));

                if (0 === count($relatedResourceNodes)) {
                    throw new \Exception('Unable to find resources.');
                }
                $relatedResourceNode = $relatedResourceNodes[0];

                $relatedResourceHrefNodes = $relatedResourceNode->xpath("link[@rel='leap2:is_part_of']/@href");

                if (0 === $relatedResourceHrefNodes) {
                    throw new \Exception("Inconsistency in resources relation, resource isn't related to any formation widget.");
                }

                $relatedResourceHrefArrayNodes = (array) $relatedResourceHrefNodes[0];

                if ((string) $formationsWidgetsNode->xpath('id')[0] !== $relatedResourceHrefArrayNodes['@attributes']['href']) {
                    throw new \Exception('Inconsistency in resources relation for formation widget.');
                }

                $relatedResourceSelfHrefNodes = $relatedResourceNode->xpath("link[@rel='self']/@href");

                if (0 === $relatedResourceSelfHrefNodes) {
                    throw new \Exception("Resource doesn't have a self link.");
                }

                $relatedResourceSelfHrefArrayNodes = (array) $relatedResourceSelfHrefNodes[0];
                $formationsWidgetResource = new FormationsWidgetResource();
                $formationsWidgetResource
                    ->setUriLabel($relatedResourceNode->title)
                    ->setUri($relatedResourceSelfHrefArrayNodes['@attributes']['href']);

                $formationsWidgetResources[] = $formationsWidgetResource;
            }
            $formationsWidget->setResources($formationsWidgetResources);
            $portfolioWidgets[] = $portfolioWidget;
        }

        return $portfolioWidgets;
    }
1000661
public function getView(AbstractWidget $widget, $widgetType)
    {
        $widgetViewEvent = new WidgetViewEvent($widgetType, $widget);

        $this->eventDispatcher->dispatch('icap_portfolio_widget_view_'.$widgetType, $widgetViewEvent);

        return $widgetViewEvent->getView();
    }
1295239
protected function getContextBackend( $templatePath = 'admin/jqadm/templates', $withView = true )
	{
		if( !isset( $this->contextBE ) )
		{
			$lang = 'en';
			$site = 'default';

			if( isset( $GLOBALS['BE_USER']->uc['lang'] ) && $GLOBALS['BE_USER']->uc['lang'] != '' ) {
				$lang = $GLOBALS['BE_USER']->uc['lang'];
			}

			if( $this->request->hasArgument( 'lang' )
				&& ( $value = $this->request->getArgument( 'lang' ) ) != ''
			) {
				$lang = $value;
			}

			if( $this->request->hasArgument( 'site' )
				&& ( $value = $this->request->getArgument( 'site' ) ) != ''
			) {
				$site = $value;
			}

			$config = Base::getConfig( (array) $this->settings );
			$context = Base::getContext( $config );

			$locale = Base::getLocaleBackend( $context, $site );
			$context->setLocale( $locale );

			$i18n = Base::getI18n( array( $lang, 'en' ), $config->get( 'i18n', array() ) );
			$context->setI18n( $i18n );

			if( $withView )
			{
				$paths = self::$aimeos->getCustomPaths( $templatePath );
				$view = Base::getView( $context, $this->uriBuilder, $paths, $this->request, $lang, false );
				$context->setView( $view );
			}

			$this->contextBE = $context;
		}

		return $this->contextBE;
	}
1334247
public function selectAsArray($withMaxPermissions = false, $withLastOpenDate = false)
    {
        $this->init();
        $this->resultAsArray = true;
        $this->joinSingleRelatives = true;
        $eol = PHP_EOL;
        $this->selectClause =
            "SELECT DISTINCT{$eol}".
            "    node.id as id,{$eol}".
            "    node.uuid as uuid,{$eol}".
            "    node.name as name,{$eol}".
            "    node.path as path,{$eol}".
            "    IDENTITY(node.parent) as parent_id,{$eol}".
            "    creator.username as creator_username,{$eol}".
            "    creator.id as creator_id,{$eol}".
            "    resourceType.name as type,{$eol}".
            "    icon.relativeUrl as large_icon,{$eol}".
            "    node.mimeType as mime_type,{$eol}".
            "    node.index as index_dir,{$eol}".
            "    node.creationDate as creation_date,{$eol}".
            "    node.modificationDate as modification_date,{$eol}".
            "    node.published as published,{$eol}".
            "    node.accessibleFrom as accessible_from,{$eol}".
            "    node.accessibleUntil as accessible_until,{$eol}".
            "    node.deletable as deletable{$eol}";

        if ($withMaxPermissions) {
            $this->leftJoinRights = true;
            $this->selectClause .= ",{$eol}rights.mask";
        }

        if ($withLastOpenDate) {
            $this->leftJoinLogs = true;
            $this->selectClause .= ",{$eol}log.dateLog as last_opened";
        }

        $this->selectClause .= $eol;

        return $this;
    }
397031
protected function with($with = null, $mode = self::MODE_OR)
    {
        if ($with instanceof GenericCollection) {
            $with = $with->toArray();
        }

        if (is_array($with)) {
            return $this->andWith((array) $with, $mode);
        }

        return $with;
    }
1260409
protected function setupWidget()
    {
        /*
         | If widget not belongs to HMVC modules and
         | has ":" in the view name, we will convert name as path
         */

        if (string_has($this->getWidgetName(), ':')) {
            $widget = null;
            $widget = str_replace(':', DS, $this->getWidgetName());

            return $this->getWidgetPath($widget, '', false);
        }
    }
1028717
public function overwriteWidget(View $view, Widget $widget)
    {
        $widgetCopy = $this->cloneEntity($widget);
        $originalWidgetMap = $widget->getWidgetMap();
        $this->widgetMapManager->overwrite($view, $originalWidgetMap, $widgetCopy);

        return $widgetCopy;
    }
435489
function getIssuerDNProp($propName, $withType = false)
    {
        switch (true) {
            case !isset($this->currentCert) || !is_array($this->currentCert):
                break;
            case isset($this->currentCert['tbsCertificate']):
                return $this->getDNProp($propName, $this->currentCert['tbsCertificate']['issuer'], $withType);
            case isset($this->currentCert['tbsCertList']):
                return $this->getDNProp($propName, $this->currentCert['tbsCertList']['issuer'], $withType);
        }

        return false;
    }
980248
public function getTableFields($table, $withPrefix = false)
    {
        $fullTable = $withPrefix ? $table : $this->getTable($table);
        if (isset($this->tableFields[$fullTable])) {
            return $this->tableFields[$fullTable];
        } else {
            $fields = array();
            switch ($this->driver) {
                case 'mysql':
                    $tableInfo = $this->fetchAll("SHOW COLUMNS FROM $fullTable");
                    $fields = $this->filter($tableInfo, 'Field');
                    break;

                case 'sqlite':
                    $tableInfo = $this->fetchAll("PRAGMA table_info($fullTable)");
                    $fields = $this->filter($tableInfo, 'name');
                    break;

                case 'pgsql':
                    $tableInfo = $this->fetchAll(
                        "SELECT column_name FROM INFORMATION_SCHEMA.COLUMNS
                        WHERE table_catalog = ? AND table_name = ?
                        ORDER BY dtd_identifier ASC",
                        array($this->dbname, $fullTable)
                    );
                    $fields = $this->filter($tableInfo, 'column_name');
            }
            if (empty($fields)) {
                // For SQLite and PostgreSQL
                throw new \PDOException(sprintf('Table or view "%s" not found', $fullTable));
            }
            return $this->tableFields[$table] = $fields;
        }
    }
1336516
public function getParents($withSelf = TRUE) {
    $node = $this;
    $parents = array();
    while ($node->getParent() != NULL) {
      $parents[] = $node->getParent();
      $node = $node->getParent();
    }
    if ($withSelf) array_unshift($parents,$this);
    return $parents;
  }
485180
private function injectWidgets(View $view, $viewWidgets)
    {
        $builtWidgetMap = $view->getBuiltWidgetMap();

        foreach ($builtWidgetMap as $slot => $widgetMaps) {
            foreach ($widgetMaps as $i => $widgetMap) {
                foreach ($viewWidgets as $widget) {
                    if ($widget->getWidgetMap() == $widgetMap) {
                        $builtWidgetMap[$slot][$i]->addWidget($widget);

                        //Override Collection default behaviour to avoid useless query
                        $builtWidgetMap[$slot][$i]->getWidgets()->setDirty(false);
                        $builtWidgetMap[$slot][$i]->getWidgets()->setInitialized(true);
                        continue;
                    }
                }
            }
        }

        $view->setBuiltWidgetMap($builtWidgetMap);
    }
1023709
public function findOrderedByRowAndCol(Portfolio $portfolio, $executeQuery = true)
    {
        $queryBuilder = $this->createQueryBuilder('pw')
            ->andWhere('pw.portfolio = :portfolio')
            ->setParameter('portfolio', $portfolio)
            ->orderBy('pw.row', 'ASC')
            ->addOrderBy('pw.col', 'ASC')
        ;

        return $executeQuery ? $queryBuilder->getQuery()->getResult() : $queryBuilder->getQuery();
    }
612110
public function findWhereNotIn($attribute, $values, $columns = ['*'], $with = [])
    {
        $values   = $this->castRequest($values);
        $cacheKey = $this->generateKey([$attribute, $values, $columns, $with]);

        return $this->cacheResults(get_called_class(), __FUNCTION__, $cacheKey, function () use ($attribute, $values, $columns, $with) {
            return $this->model->with($with)
                ->whereNotIn($attribute, $values)
                ->get($columns);
        });
    }
757089
def portfolio(self) -> List[PortfolioItem]:
        
        account = self.wrapper.accounts[0]
        return [v for v in self.wrapper.portfolio[account].values()]