/**
  * Create service
  *
  * @param ServiceLocatorInterface $serviceLocator
  *
  * @return mixed
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $auth = $serviceLocator->get('AuthenticationService');
     $user = $auth->getUser();
     $settings = $user->getSettings('Orders');
     $invoiceAddress = $settings->getInvoiceAddress();
     if (!$invoiceAddress->getCompany()) {
         $invoiceAddress = false;
         $org = $user->getOrganization();
         if ($org->isEmployee()) {
             $orgUser = $org->isHiringOrganization() ? $org->getParent()->getUser() : $org->getUser();
             $invoiceAddress = $orgUser->getSettings('Orders')->getInvoiceAddress();
             if (!$invoiceAddress->getCompany()) {
                 $invoiceAddress = false;
             }
         }
     }
     $entity = new InvoiceAddress();
     if ($invoiceAddress) {
         $entityHydrator = new EntityHydrator();
         $settingsHydrator = new SettingsEntityHydrator();
         $data = $settingsHydrator->extract($invoiceAddress);
         $entity = $entityHydrator->hydrate($data, $entity);
     }
     return $entity;
 }
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $form = new Form();
     $serviceLocator->injectFactory($form);
     $form->add(array('type' => $this->fileElement, 'name' => $this->fileName, 'attributes' => array('class' => 'hide')));
     $form->get($this->fileName)->setIsMultiple($this->multiple);
     $user = $serviceLocator->getServiceLocator()->get('AuthenticationService')->getUser();
     $fileEntity = new $this->fileEntityClass();
     if ($user instanceof AnonymousUser) {
         $fileEntity->getPermissions()->grant($user, 'all');
     } else {
         $fileEntity->setUser($user);
     }
     $strategy = new FileUploadStrategy($fileEntity);
     if ($this->multiple) {
         $hydrator = new FileCollectionUploadHydrator($this->fileName, $strategy);
         $form->add(array('type' => 'button', 'name' => 'remove', 'options' => array('label' => 'Remove all'), 'attributes' => array('class' => 'fu-remove-all btn btn-danger btn-xs pull-right')));
     } else {
         $hydrator = new EntityHydrator();
         $hydrator->addStrategy($this->fileName, $strategy);
     }
     $form->setHydrator($hydrator);
     $form->setOptions(array('use_files_array' => true));
     $this->configureForm($form);
     return $form;
 }
Esempio n. 3
0
 /**
  * Inherit data from an {@link UserInfoInterface}.
  *
  * Copies the user image to an application attachment.
  * @param InfoInterface $info
  * @return $this
  */
 public function inherit(InfoInterface $info)
 {
     $hydrator = new EntityHydrator();
     $imageStrategy = new FileCopyStrategy(new Attachment());
     $hydrator->addStrategy('image', $imageStrategy);
     $data = $hydrator->extract($info);
     $hydrator->hydrate($data, $this);
     return $this;
 }
 public function getHydrator()
 {
     if (!$this->hydrator) {
         $hydrator = new EntityHydrator();
         $collectionStrategy = new CollectionStrategy();
         $hydrator->addStrategy('educations', $collectionStrategy)->addStrategy('employments', $collectionStrategy)->addStrategy('skills', $collectionStrategy);
         $this->setHydrator($hydrator);
     }
     return $this->hydrator;
 }
Esempio n. 5
0
 public function getHydrator()
 {
     if (!$this->hydrator) {
         $hydrator = new EntityHydrator();
         $collectionStrategy = new CollectionStrategy();
         $hydrator->addStrategy('nativeLanguages', $collectionStrategy)->addStrategy('languageSkills', $collectionStrategy);
         $this->setHydrator($hydrator);
     }
     return $this->hydrator;
 }
Esempio n. 6
0
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $services = $serviceLocator->getServiceLocator();
     $user = $services->get('AuthenticationService')->getUser();
     $fieldset = new UserInfoFieldset();
     $imageEntity = new UserImage();
     $imageEntity->setUser($user);
     $strategy = new FileUploadStrategy($imageEntity);
     $hydrator = new EntityHydrator();
     $hydrator->addStrategy('image', $strategy);
     $fieldset->setHydrator($hydrator);
     return $fieldset;
 }
 public function getHydrator()
 {
     if (!$this->hydrator) {
         $hydrator = new EntityHydrator();
         $formFactory = $this->getFormFactory();
         $formElementManager = $formFactory->getFormElementManager();
         $serviceLocator = $formElementManager->getServiceLocator();
         $repositoryManager = $serviceLocator->get('repositories');
         $repOrganizationName = $repositoryManager->get('Organizations/OrganizationName');
         $organizationName = new OrganizationNameStrategy($repOrganizationName);
         $hydrator->addStrategy('organizationName', $organizationName);
         $this->setHydrator($hydrator);
     }
     return $this->hydrator;
 }
 /**
  * Creates fieldset
  * {@inheritdoc}
  *
  * @return EmployeesFieldset
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     /* @var $serviceLocator \Zend\ServiceManager\AbstractPluginManager
      * @var $headscript     \Zend\View\Helper\HeadScript */
     $services = $serviceLocator->getServiceLocator();
     $helpers = $services->get('ViewHelperManager');
     $headscript = $helpers->get('headscript');
     $basepath = $helpers->get('basepath');
     $fieldset = new EmployeesFieldset();
     $hydrator = new EntityHydrator();
     $hydrator->addStrategy('employees', new CollectionStrategy());
     $fieldset->setHydrator($hydrator);
     $headscript->appendFile($basepath('Organizations/js/organizations.employees.js'));
     return $fieldset;
 }
Esempio n. 9
0
 public function extract($object)
 {
     $data = parent::extract($object);
     // provide the fieldset access to the entity
     // (since it is changing properties of the user)
     $data['passwordFieldset'] = $object;
     return $data;
 }
Esempio n. 10
0
 public function hydrate(array $data, $object)
 {
     $object = parent::hydrate($data, $object);
     $this->hydrateValue('descriptiondescription', $data, $object);
     $this->hydrateValue('descriptionrequirements', $data, $object);
     $this->hydrateValue('descriptionbenefits', $data, $object);
     $this->hydrateValue('descriptionqualifications', $data, $object);
     $this->hydrateValue('descriptiontitle', $data, $object);
     return $object;
 }
 public function hydrate(array $data, $object)
 {
     /** @var Entity\Job $object */
     $object = parent::hydrate($data, $object);
     /** @var Organization $organization */
     if ($organization = $this->organizationRepository->find($data['companyId'])) {
         $object->setOrganization($organization);
     } else {
         $object->setOrganization(null);
     }
     return $object;
 }
 public function hydrate(array $data, $object)
 {
     $object = parent::hydrate($data, $object);
     /* @var \Organizations\Entity\Template  $template */
     $template = $object->getOrganization()->getTemplate();
     if (isset($data['description-label-requirements'])) {
         $template->setLabelRequirements($data['description-label-requirements']);
     }
     if (isset($data['description-label-qualifications'])) {
         $template->setLabelQualifications($data['description-label-qualifications']);
     }
     if (isset($data['description-label-benefits'])) {
         $template->setLabelBenefits($data['description-label-benefits']);
     }
     return $object;
 }
Esempio n. 13
0
 /**
  * makes a recursiv difference between array1 and array2
  * found commands like  'array_diff_assoc' wanting
  *
  * the result looks like
  * key => array( old, new)
  * in subarrays it looks like
  * key.subkey = array( old, new)
  *
  * @param $array1
  * @param $array2
  * @param int $maxDepth
  * @return array
  */
 protected function array_compare($array1, $array2, $maxDepth = 2)
 {
     $result = array();
     $arraykeys = array_unique(array_merge(array_keys($array1), array_keys($array2)));
     foreach ($arraykeys as $key) {
         if (!empty($key) && is_string($key) && $key[0] != "" && substr($key, 0, 8) != 'Doctrine') {
             if (array_key_exists($key, $array1) && !array_key_exists($key, $array2)) {
                 $result[$key] = array($array1[$key], '');
             }
             if (!array_key_exists($key, $array1) && array_key_exists($key, $array2)) {
                 $result[$key] = array('', $array2[$key]);
             }
             if (array_key_exists($key, $array1) && array_key_exists($key, $array2)) {
                 $subResult = null;
                 if (is_array($array1[$key]) && is_array($array2[$key])) {
                     if (0 < $maxDepth) {
                         $subResult = $this->array_compare($array1[$key], $array2[$key], $maxDepth - 1);
                     }
                 } elseif (is_object($array1[$key]) && is_object($array2[$key])) {
                     if (0 < $maxDepth) {
                         $hydrator = new EntityHydrator();
                         $a1 = $hydrator->extract($array1[$key]);
                         $a2 = $hydrator->extract($array2[$key]);
                         $subResult = $this->array_compare($a1, $a2, $maxDepth - 1);
                     }
                 } else {
                     if ($array1[$key] != $array2[$key]) {
                         $result[$key] = array($array1[$key], $array2[$key]);
                     }
                 }
                 if (!empty($subResult)) {
                     foreach ($subResult as $subKey => $subValue) {
                         if (!empty($subKey) && is_string($subKey)) {
                             $result[$key . '.' . $subKey] = $subValue;
                         }
                     }
                 }
             }
         }
     }
     return $result;
 }
Esempio n. 14
0
 /**
  * The configuration from the FileUploadFactory configuration
  *
  * @param ServiceLocatorInterface $serviceLocator
  * @return Form
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     /* @var $serviceLocator \Zend\Form\FormElementManager */
     $service = $serviceLocator->getServiceLocator();
     $options = null;
     if ($this->options) {
         $options = $service->get($this->options);
     }
     // Retrieve configuration.
     if ($this->configKey) {
         $services = $serviceLocator->getServiceLocator();
         $config = $services->get('config');
         $config = isset($config['form_elements_config']['file_upload_factories'][$this->configKey]) ? $config['form_elements_config']['file_upload_factories'][$this->configKey] : array();
         $this->config = $config;
     }
     $form = new Form();
     $serviceLocator->injectFactory($form);
     $form->add(array('type' => $this->fileElement, 'name' => $this->fileName, 'options' => array('use_formrow_helper' => false), 'attributes' => array('class' => 'hide')));
     /* @var $element \Core\Form\Element\FileUpload */
     $element = $form->get($this->fileName);
     $element->setIsMultiple($this->multiple);
     $user = $serviceLocator->getServiceLocator()->get('AuthenticationService')->getUser();
     /* @var $fileEntity \Core\Entity\FileInterface */
     $fileEntity = new $this->fileEntityClass();
     if ($user instanceof AnonymousUser) {
         $fileEntity->getPermissions()->grant($user, 'all');
     } else {
         $fileEntity->setUser($user);
     }
     $strategy = new FileUploadStrategy($fileEntity);
     if ($this->multiple) {
         $hydrator = new FileCollectionUploadHydrator($this->fileName, $strategy);
         $form->add(array('type' => 'button', 'name' => 'remove', 'options' => array('label' => 'Remove all'), 'attributes' => array('class' => 'fu-remove-all btn btn-danger btn-xs pull-right')));
     } else {
         $hydrator = new EntityHydrator();
         $hydrator->addStrategy($this->fileName, $strategy);
     }
     $form->setHydrator($hydrator);
     $form->setOptions(array('use_files_array' => true));
     $this->configureForm($form, $options);
     return $form;
 }
Esempio n. 15
0
 public function hydrate(array $data, $object)
 {
     $object = parent::hydrate($data, $object);
     return $object;
 }
 public function getInvoiceAddressEntity()
 {
     $hydrator = new EntityHydrator();
     $data = $this->getSettings();
     $entity = $hydrator->hydrate($data, new InvoiceAddress());
     return $entity;
 }
Esempio n. 17
0
 /**
  * Hydrate a TemplateValues entity with the provided $data including the configured FreeValues.
  *
  * @param  array          $data
  * @param  TemplateValues $object
  *
  * @return TemplateValues
  */
 public function hydrate(array $data, $object)
 {
     parent::hydrate($data, $object);
     foreach ($this->getFreeValuesKeys() as $key) {
         if (isset($data[$key])) {
             $object->set($key, $data[$key]);
         }
     }
     return $object;
 }