/** * @param WidgetManagerInterface $widgetManager * @param int $pageId */ public function __construct(WidgetManagerInterface $widgetManager, $pageId) { parent::__construct(); $this->widgetManager = $widgetManager; $widgets = $widgetManager->getWidgetsByPage($pageId); $blocks = $widgetManager->getPageWidgetBlocks($pageId); foreach ($widgets as $widget) { $this->addWidget($widget, array_get($blocks, $widget->getId() . '.0'), array_get($blocks, $widget->getId() . '.1')); } }
/** * @return string */ public function getTypeTitle() { foreach ($this->widgetManager->getAvailableTypes() as $group => $types) { if (isset($types[$this->type])) { return $types[$this->type]; } } return $this->type; }
/** * @param WidgetManager $widgetManager * @param WidgetRepository $repository * @param int $id * * @return \Illuminate\Http\RedirectResponse */ public function postLocation(WidgetManager $widgetManager, WidgetRepository $repository, $id) { $repository->findOrFail($id); $widgetManager->placeWidgetsOnPages($id, $this->request->input('blocks', [])); return back(); }
/** * @return bool */ public function isCorrupt() { return $this->manager->isCorrupt(get_class($this->toWidget())); }