Example #1
0
 public function updateGadgetContainer(GadgetContainer $gadgetContainer, array $data)
 {
     $gadgets = [];
     if (array_key_exists('layout', $data)) {
         $gadgetContainer->setLayout($data['layout']);
     }
     if (array_key_exists('gadgets', $data)) {
         foreach ($data['gadgets'] as $gadget) {
             $gadgetEntity = null;
             if ($gadget['id']) {
                 $gadgetEntity = $gadgetContainer->getGadget($gadget['id']);
             }
             if (!$gadgetEntity) {
                 $gadgetEntity = new GadgetEntity($gadgetContainer, $gadget['type']);
             }
             $gadgetEntity->setColumn($gadget['column']);
             $gadgetEntity->setPosition($gadget['position']);
             $this->entityManager->persist($gadgetEntity);
             $gadgets[] = $gadgetEntity;
         }
     }
     $this->entityManager->flush();
     $result = [];
     foreach ($gadgets as $gadget) {
         $result[] = $gadget->getId()->toString();
     }
     return $result;
 }
Example #2
0
 private function extractGadgets(GadgetContainer $item)
 {
     $result = [];
     foreach ($item->getGadgets() as $gadget) {
         $result[] = new GadgetEntity($gadget);
     }
     return new Collection($result);
 }
Example #3
0
 public function __invoke(GadgetContainerObject $gadgetContainer, array $options)
 {
     $this->options = $options;
     $attribs = [];
     $attribs['class'] = 'zui-gadgets';
     $attribs['data-zource-container-load-url'] = $this->getView()->url($options['load_url']);
     $attribs['data-zource-container-update-container-url'] = $options['update_container_url'];
     $attribs['data-zource-container-layout'] = $gadgetContainer->getLayout();
     $attribs['data-zource-empty-msg'] = 'No gadgets added yet.';
     $html = sprintf('<div %s>', $this->renderAttribs($attribs));
     $html .= $this->renderColumns($gadgetContainer);
     $html .= '</div>';
     return $html;
 }