Ejemplo n.º 1
0
 /**
  * Hydration handler for the legacy object.
  *
  * @param HydrationEvent $event
  */
 public function hydrateLegacyHandler(HydrationEvent $event)
 {
     $entity = $event->getArgument('entity');
     if (get_class($entity) === 'Bolt\\Storage\\Entity\\Content') {
         $entity->setLegacyService($this->legacy);
     }
 }
Ejemplo n.º 2
0
 /**
  * Hydration handler for the legacy object.
  *
  * @param HydrationEvent $event
  */
 public function hydrateLegacyHandler(HydrationEvent $event)
 {
     $entity = $event->getArgument('entity');
     if ($entity instanceof Content) {
         $entity->setLegacyService($this->legacy);
     }
 }
Ejemplo n.º 3
0
 /**
  * Post hydration storage event.
  *
  * @param HydrationEvent $event
  */
 public function onPostHydrate(HydrationEvent $event)
 {
     $entity = $event->getSubject();
     if (!$entity instanceof Entity\Users) {
         return;
     }
     // Ensure Permissions::ROLE_EVERYONE always exists
     $roles = $entity->getRoles();
     if (!in_array(Permissions::ROLE_EVERYONE, $roles)) {
         $roles[] = Permissions::ROLE_EVERYONE;
         $entity->setRoles($roles);
     }
 }
Ejemplo n.º 4
0
 public function hydrateLegacyHandler(HydrationEvent $event)
 {
     $entity = $event->getSubject();
     $entity->setLegacyService($this->legacy);
 }
 /**
  * StorageEvents::POST_HYDRATE event callback.
  *
  * @param HydrationEvent $event
  */
 public function postHydrate(HydrationEvent $event)
 {
     $request = $this->requestStack->getCurrentRequest();
     if ($request === null) {
         return;
     }
     $localeSlug = $request->get('_locale');
     /** @var Content $subject */
     $subject = $event->getSubject();
     if (!$subject instanceof Content || $request->request->getBoolean('no_locale_hydrate')) {
         return;
     }
     $contentTypeName = $subject->getContenttype();
     $contentType = $this->boltConfig->get('contenttypes/' . $contentTypeName);
     if (!isset($subject[$localeSlug . 'data'])) {
         return;
     }
     $localeData = json_decode($subject[$localeSlug . 'data'], true);
     foreach ($localeData as $key => $value) {
         if ($key === 'templatefields') {
             $templateFields = $this->boltConfig->get('theme/templatefields/' . $subject['template'] . '/fields');
             foreach ($templateFields as $key => $field) {
                 if ($field['type'] === 'repeater') {
                     $repeaterData = json_decode($value[$key], true);
                     /** @var RepeatingFieldCollection[] $subject */
                     $subject['templatefields'][$key]->clear();
                     foreach ($repeaterData as $subValue) {
                         $subject['templatefields'][$key]->addFromArray($subValue);
                     }
                 }
             }
         }
         if ($contentType['fields'][$key]['type'] !== 'repeater') {
             continue;
         }
         /** @var RepeatingFieldCollection[] $subject */
         $subject[$key]->clear();
         foreach ($value as $subValue) {
             $subject[$key]->addFromArray($subValue);
         }
     }
 }