Ejemplo n.º 1
0
 /**
  * @param Portfolio $portfolio
  * @param string    $type
  *
  * @return \Icap\PortfolioBundle\Entity\PortfolioWidget
  */
 public function createPortfolioWidget(Portfolio $portfolio, $type)
 {
     if (!$this->widgetTypeManager->isWidgetTypeExists($type)) {
         throw new \InvalidArgumentException();
     }
     $portfolioWidget = new PortfolioWidget();
     $portfolioWidget->setPortfolio($portfolio)->setWidgetType($type);
     return $portfolioWidget;
 }
Ejemplo n.º 2
0
 /**
  * @param Portfolio $portfolio
  * @param User      $user
  * @param string    $widgetType
  *
  * @return \Icap\PortfolioBundle\Entity\PortfolioWidget[]
  */
 public function getPortfolioWidgetsForWidgetPicker(Portfolio $portfolio, User $user, $widgetType)
 {
     $portfolioWidgets = [];
     $widgets = $this->getWidgets($user, $widgetType);
     foreach ($widgets as $widget) {
         $portfolioWidget = new PortfolioWidget();
         $portfolioWidget->setPortfolio($portfolio)->setWidget($widget)->setWidgetType($widgetType)->setSize($this->getWidgetSizeByType($widgetType));
         $portfolioWidgets[] = $portfolioWidget;
     }
     return $portfolioWidgets;
 }