예제 #1
0
 /**
  * {@inheritdoc}
  */
 public function extract($object)
 {
     $data = $this->decoratedHydrator->extract($object);
     if (isset($data['parents']) && $data['parents'] instanceof Collection) {
         $data['parents'] = $data['parents']->toArray();
     }
     return $data;
 }
 public function delete(EntityInterface $entity)
 {
     $primaryKey = $this->getPrimaryKey();
     $data = $this->hydrator->extract($entity);
     if (isset($data[$primaryKey]) && $data[$primaryKey] > 0) {
         $this->db->delete()->from('main_table', $this->getMainTable())->where('main_table.' . $primaryKey . '=?', $data[$primaryKey])->run();
         return true;
     }
     return false;
 }
예제 #3
0
 /** {@inheritdoc} */
 public function extract($object)
 {
     return array_change_key_case($this->_hydrator->extract($object), CASE_UPPER);
 }
예제 #4
0
 function it_merges_two_themes_with_each_other_without_changing_the_id(HydratorInterface $themeHydrator, ThemeInterface $existingTheme, ThemeInterface $loadedTheme)
 {
     $themeHydrator->extract($loadedTheme)->willReturn(['id' => null, 'name' => 'theme/name', 'path' => 'another/path']);
     $themeHydrator->hydrate(['name' => 'theme/name', 'path' => 'another/path'], $existingTheme)->shouldBeCalled()->willReturn($existingTheme);
     $this->merge($existingTheme, $loadedTheme)->shouldReturn($existingTheme);
 }
 /**
  * Callback to be used when {@see ExtractEvent::EVENT_EXTRACT} is triggered
  *
  * @param ExtractEvent $event
  * @return array
  * @internal
  */
 public function onExtract(ExtractEvent $event)
 {
     $data = $this->hydrator->extract($event->getExtractionObject());
     $event->mergeExtractedData($data);
     return $data;
 }
예제 #6
0
 /**
  * Extracts parameters from object and returns an array
  *
  * @param $obj
  * @return array
  */
 public function extract($obj)
 {
     return $this->hydrator->extract($obj);
 }
예제 #7
0
 /**
  * {@inheritdoc}
  */
 public function merge(ThemeInterface $existingTheme, ThemeInterface $loadedTheme)
 {
     $loadedThemeProperties = $this->themeHydrator->extract($loadedTheme);
     unset($loadedThemeProperties['id']);
     return $this->themeHydrator->hydrate($loadedThemeProperties, $existingTheme);
 }
 /**
  * Extract values from an object.
  *
  * @param object $object
  *
  * @return array
  */
 public function extract($object)
 {
     return $this->extractService->extract($object);
 }
예제 #9
0
 function it_proxies_extracting_and_converts_parents_to_array_if_needed(HydratorInterface $decoratedHydrator, Collection $collection)
 {
     $decoratedHydrator->extract('object')->willReturn(['data' => 'data', 'parents' => $collection]);
     $collection->toArray()->willReturn(['parent object']);
     $this->extract('object')->shouldReturn(['data' => 'data', 'parents' => ['parent object']]);
 }