@param Portfolio $portfolio

@return array
776284
public function getPortfolioData(Portfolio $portfolio)
    {
        /** @var \Icap\PortfolioBundle\Entity\PortfolioWidget[] $portfolioWidgets */
        $portfolioWidgets = $this->widgetsManager->getByPortfolioForGridster($portfolio);
        /** @var \Icap\PortfolioBundle\Entity\PortfolioComment[] $comments */
        $comments = $this->entityManager->getRepository('IcapPortfolioBundle:PortfolioComment')->findSome($portfolio);

        $data = [
            'id' => $portfolio->getId(),
            'title' => $portfolio->getTitle(),
            'portfolioWidgets' => [],
        ];

        foreach ($portfolioWidgets as $portfolioWidget) {
            $data['portfolioWidgets'][] = $this->widgetsManager->getPortfolioWidgetData($portfolioWidget);
        }

        $commentsDatas = [];

        foreach ($comments as $comment) {
            $commentsDatas[] = $comment->getData();
        }
        $data['comments'] = $commentsDatas;
        $data['unreadComments'] = $portfolio->getCountUnreadComments();
        $data['commentsViewAt'] = $portfolio->getCommentsViewAt()->format(DATE_W3C);

        return $data;
    }
251995
public function get($field) {
        if ($field == 'format') {
            return portfolio_format_object($this->format);
        } else if ($field == 'formatclass') {
            return $this->format;
        }
        if (property_exists($this, $field)) {
            return $this->{$field};
        }
        $a = (object)array('property' => $field, 'class' => get_class($this));
        throw new portfolio_export_exception($this, 'invalidproperty', 'portfolio', null, $a);
    }
1184914
private function getSuiteFilters(Suite $suite)
    {
        if (!$suite->hasSetting('filters') || !is_array($suite->getSetting('filters'))) {
            return array();
        }

        $filters = array();
        foreach ($suite->getSetting('filters') as $type => $filterString) {
            $filters[] = $this->createFilter($type, $filterString, $suite);
        }

        return $filters;
    }
720640
public function manageGuidesAction(Request $request, User $loggedUser, Portfolio $portfolio)
    {
        try {
            if ($this->getPortfolioFormHandler()->handleGuides($portfolio)) {
                if ($request->isXmlHttpRequest()) {
                    return new Response($this->refreshPortfolioList($loggedUser));
                } else {
                    $this->getSessionFlashbag()
                        ->add('success', $this->getTranslator()
                            ->trans('portfolio_guides_update_success_message', [], 'icap_portfolio'));

                    return $this->redirect($this->generateUrl('icap_portfolio_index'));
                }
            }
        } catch (\Exception $exception) {
            $this->getSessionFlashbag()->add('error', $this->getTranslator()->trans('portfolio_guides_update_error_message', [], 'icap_portfolio'));

            return $this->redirect($this->generateUrl('icap_portfolio_index'));
        }

        return [
            'form' => $this->getPortfolioFormHandler()->getGuidesForm($portfolio)->createView(),
            'portfolio' => $portfolio,
        ];
    }
148165
public function show(PortfolioRequest $request, Portfolio $portfolio)
    {

        if ($portfolio->exists) {
            $view = 'portfolio::portfolio.show';
        } else {
            $view = 'portfolio::portfolio.new';
        }

        return $this->response->title(trans('app.view') . ' ' . trans('portfolio::portfolio.name'))
            ->data(compact('portfolio'))
            ->view($view, true)
            ->output();
    }
757089
def portfolio(self) -> List[PortfolioItem]:
        
        account = self.wrapper.accounts[0]
        return [v for v in self.wrapper.portfolio[account].values()]
692342
public function setPortfolioTeams($portfolioTeams)
    {
        foreach ($portfolioTeams as $portfolioTeam) {
            $portfolioTeam->setPortfolio($this);
        }

        $this->portfolioTeams = $portfolioTeams;

        return $this;
    }
742008
def get_account(self, portfolio_cookie: str, account_cookie: str):
        

        try:
            return self.portfolio_list[portfolio_cookie][account_cookie]
        except:
            return None
761949
public function getOpeningMode(Portfolio $portfolio, $user, $isAdmin = false)
    {
        $openingMode = null;

        if (null !== $user) {
            if ($user === $portfolio->getUser() || $isAdmin) {
                $openingMode = self::PORTFOLIO_OPENING_MODE_EDIT;
            } elseif ($portfolio->hasGuide($user)) {
                $openingMode = self::PORTFOLIO_OPENING_MODE_EVALUATE;
            } elseif ($this->visibleToUser($portfolio, $user)) {
                $openingMode = self::PORTFOLIO_OPENING_MODE_VIEW;
            }
        } elseif (Portfolio::VISIBILITY_EVERYBODY === $portfolio->getVisibility()) {
            $openingMode = self::PORTFOLIO_OPENING_MODE_VIEW;
        }

        return $openingMode;
    }
666587
public static function getList(string $module) : array
    {
        $default = Configure::read('CsvMigrations.ValidateShell.module._default');
        $result = Configure::read('CsvMigrations.ValidateShell.module.' . $module);
        $result = empty($result) ? $default : $result;
        $result = empty($result['checks']) ? [] : $result['checks'];

        return $result;
    }
921116
public function getUsageReferences(AssetInterface $asset)
    {
        $usages = [];
        /** @var AssetUsageStrategyInterface $strategy */
        foreach ($this->getUsageStrategies() as $strategy) {
            $usages = Arrays::arrayMergeRecursiveOverrule($usages, $strategy->getUsageReferences($asset));
        }

        return $usages;
    }
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;
    }
818301
private function extractUserInformationWidgets(\SimpleXMLElement $nodes, Portfolio $portfolio)
    {
        $userInformationWidgetNodes = $nodes->xpath("//entry[rdf:type/@rdf:resource='leap2:person']");
        $portfolioWidgets = [];

        if (0 < count($userInformationWidgetNodes)) {
            $birthDateNode = $userInformationWidgetNodes[0]->xpath("leap2:persondata[@leap2:field='dob']");
            $birthDate = (string) $birthDateNode[0];

            $cityNode = $userInformationWidgetNodes[0]->xpath("leap2:persondata[@leap2:field='other' and @leap2:label='city']");
            $city = (string) $cityNode[0];
            $portfolioWidget = $this->widgetsManager->getNewPortfolioWidget($portfolio, 'userInformation');
            $userInformationWidget = new UserInformationWidget();
            $portfolioWidget->setWidget($userInformationWidget);
            $userInformationWidget->setUser($portfolio->getUser());
            $userInformationWidget
                ->setLabel((string) $userInformationWidgetNodes[0]->title)
                ->setBirthDate(new \DateTime($birthDate))
                ->setCity($city);

            $portfolioWidgets[] = $portfolioWidget;
        }

        return $portfolioWidgets;
    }
8728
public function apply(Value $value): array
    {
        $filter   = $this->filter;
        $errors   = [];
        $filtered = $filter($value, $errors);
        if (count($errors) > 0) {
            return $this->errors($errors);
        }

        return $this->filtered($filtered);
    }
678817
public function getAllAction(User $loggedUser, Portfolio $portfolio)
    {
        $this->checkPortfolioToolAccess($loggedUser, $portfolio);

        $response = new JsonResponse($this->getCommentsManager()->getCommentsByPortfolio($portfolio), Response::HTTP_OK);

        return $response;
    }
82459
public function setPortfolioUsers($portfolioUsers)
    {
        foreach ($portfolioUsers as $portfolioUser) {
            $portfolioUser->setPortfolio($this);
        }

        $this->portfolioUsers = $portfolioUsers;

        return $this;
    }
1230666
public function renameAction(Request $request, User $loggedUser, Portfolio $portfolio)
    {
        $this->checkPortfolioToolAccess();

        try {
            if ($this->getPortfolioFormHandler()->handleRename($portfolio)) {
                if ($request->isXmlHttpRequest()) {
                    return new Response($this->refreshPortfolioList($loggedUser));
                } else {
                    $this->getSessionFlashbag()
                        ->add('success', $this->getTranslator()
                            ->trans('portfolio_rename_success_message', [], 'icap_portfolio'));

                    return $this->redirect($this->generateUrl('icap_portfolio_index'));
                }
            }
        } catch (\Exception $exception) {
            if ($request->isXmlHttpRequest()) {
                return new JsonResponse('Error while renaming the portfolio', 500);
            } else {
                $this->getSessionFlashbag()
                    ->add('error', $this->getTranslator()
                        ->trans('portfolio_rename_error_message', [], 'icap_portfolio'));
            }

            return $this->redirect($this->generateUrl('icap_portfolio_index'));
        }

        return [
            'form' => $this->getPortfolioFormHandler()->getRenameForm($portfolio)->createView(),
            'portfolio' => $portfolio,
        ];
    }