/**
  * Reorder the children of the parent form data at $this->name.
  *
  * For whatever reason we have to go through the parent object, just
  * getting the collection from the form event and reordering it does
  * not update the stored order.
  *
  * @param FormEvent $event
  */
 public function onSubmit(FormEvent $event)
 {
     $form = $event->getForm()->getParent();
     $data = $form->getData();
     if (!is_object($data)) {
         return;
     }
     $accessor = PropertyAccess::getPropertyAccessor();
     // use deprecated BC method to support symfony 2.2
     $newCollection = $accessor->getValue($data, $this->name);
     if (!$newCollection instanceof Collection) {
         return;
     }
     /* @var $newCollection Collection */
     $newCollection->clear();
     /** @var $item FormBuilder */
     foreach ($form->get($this->name) as $key => $item) {
         if ($item->get('_delete')->getData()) {
             // do not re-add a deleted child
             continue;
         }
         if ($item->getName() && !is_numeric($item->getName())) {
             // keep key in collection
             $newCollection[$item->getName()] = $item->getData();
         } else {
             $newCollection[] = $item->getData();
         }
     }
 }
 /**
  * {@inheritdoc}
  */
 public function current()
 {
     $current = $this->iterator->current();
     $data = array();
     foreach ($this->propertyPaths as $name => $propertyPath) {
         $data[$name] = $this->getValue($this->propertyAccessor->getValue($current, $propertyPath));
     }
     return $data;
 }
 /**
  * {@inheritdoc}
  */
 public function current()
 {
     $current = $this->iterator->current();
     $data = array();
     foreach ($this->propertyPaths as $name => $propertyPath) {
         $data[$name] = $this->getValue($this->propertyAccessor->getValue($current, $propertyPath));
     }
     $this->query->getDocumentManager()->getUnitOfWork()->detach($current);
     return $data;
 }
 /**
  * {@inheritdoc}
  */
 public function current()
 {
     $current = $this->iterator->current();
     $data = array();
     foreach ($this->propertyPaths as $name => $propertyPath) {
         try {
             $data[$name] = $this->getValue($this->propertyAccessor->getValue($current[0], $propertyPath));
         } catch (UnexpectedTypeException $e) {
             //non existent object in path will be ignored
             $data[$name] = null;
         }
     }
     $this->query->getEntityManager()->getUnitOfWork()->detach($current[0]);
     return $data;
 }
Exemple #5
0
 /**
  * @dataProvider propertiesDataProvider
  * @param string $property
  * @param mixed  $value
  */
 public function testSettersAndGetters($property, $value)
 {
     $emailThread = new EmailThread();
     $accessor = PropertyAccess::createPropertyAccessor();
     $accessor->setValue($emailThread, $property, $value);
     $this->assertEquals($value, $accessor->getValue($emailThread, $property));
 }
 /**
  * Construct
  */
 public function __construct()
 {
     $this->accessor = PropertyAccess::createPropertyAccessor();
     foreach ($this->getFieldDefinitions() as $field) {
         $this->fields[$field->getName()] = $field;
     }
 }
 /**
  * Constructor
  *
  * @param ObjectRepository          $repository
  * @param bool                      $multiple
  * @param PropertyAccessorInterface $propertyAccessor
  * @param string                    $delimiter
  */
 public function __construct(ObjectRepository $repository, $multiple, PropertyAccessorInterface $propertyAccessor = null, $delimiter = ',')
 {
     $this->repository = $repository;
     $this->multiple = $multiple;
     $this->propertyAccessor = $propertyAccessor ?: PropertyAccess::createPropertyAccessor();
     $this->delimiter = $delimiter;
 }
 /**
  * @param object             $entity
  * @param ContainerInterface $container
  *
  * @return array
  */
 public function __invoke($entity, ContainerInterface $container)
 {
     /* @var EntityManager $em */
     $em = $container->get('doctrine.orm.entity_manager');
     if (!$this->accessor) {
         $this->accessor = PropertyAccess::createPropertyAccessor();
     }
     $meta = $em->getClassMetadata(get_class($entity));
     $result = array();
     foreach ($meta->getFieldNames() as $fieldName) {
         $result[$fieldName] = $this->accessor->getValue($entity, $fieldName);
     }
     $hasToStringMethod = in_array('__toString', get_class_methods(get_class($entity)));
     foreach ($meta->getAssociationNames() as $fieldName) {
         if (isset($this->associativeFieldMappings[$fieldName])) {
             $expression = $this->associativeFieldMappings[$fieldName];
             $result[$fieldName] = $this->accessor->getValue($entity, $expression);
         } elseif ($hasToStringMethod) {
             $result[$fieldName] = $entity->__toString();
         }
     }
     $finalResult = array();
     foreach ($result as $fieldName => $fieldValue) {
         if (in_array($fieldName, $this->excludedFields)) {
             continue;
         }
         $finalResult[$fieldName] = $fieldValue;
     }
     return $finalResult;
 }
Exemple #9
0
 /**
  * @param $data array
  * @param format string, either rss or atom
  */
 protected function createFeed(View $view, Request $request)
 {
     $feed = new Feed();
     $data = $view->getData();
     $item = current($data);
     $annotationData = $this->reader->read($item);
     if ($item && ($feedData = $annotationData->getFeed())) {
         $class = get_class($item);
         $feed->setTitle($feedData->getName());
         $feed->setDescription($feedData->getDescription());
         $feed->setLink($this->urlGen->generateCollectionUrl($class));
         $feed->setFeedLink($this->urlGen->generateCollectionUrl($class, $request->getRequestFormat()), $request->getRequestFormat());
     } else {
         $feed->setTitle('Camdram feed');
         $feed->setDescription('Camdram feed');
     }
     $lastModified = null;
     $accessor = PropertyAccess::createPropertyAccessor();
     // Add one or more entries. Note that entries must be manually added once created.
     foreach ($data as $document) {
         $entry = $feed->createEntry();
         $entry->setTitle($accessor->getValue($document, $feedData->getTitleField()));
         $entry->setLink($this->urlGen->generateUrl($document));
         $entry->setDescription($this->twig->render($feedData->getTemplate(), array('entity' => $document)));
         if ($accessor->isReadable($document, $feedData->getUpdatedAtField())) {
             $entry->setDateModified($accessor->getValue($document, $feedData->getUpdatedAtField()));
         }
         $feed->addEntry($entry);
         if (!$lastModified || $entry->getDateModified() > $lastModified) {
             $lastModified = $entry->getDateModified();
         }
     }
     $feed->setDateModified($lastModified);
     return $feed->export($request->getRequestFormat());
 }
 /**
  * @return \Symfony\Component\PropertyAccess\PropertyAccessor
  */
 protected function getPropertyAccessor()
 {
     if (!$this->propertyAccessor) {
         $this->propertyAccessor = PropertyAccess::createPropertyAccessor();
     }
     return $this->propertyAccessor;
 }
Exemple #11
0
 /**
  * @Route("attachment/{codedString}.{extension}",
  *   name="oro_attachment_file",
  *   requirements={"extension"="\w+"}
  * )
  */
 public function getAttachmentAction($codedString, $extension)
 {
     list($parentClass, $fieldName, $parentId, $type, $filename) = $this->get('oro_attachment.manager')->decodeAttachmentUrl($codedString);
     $parentEntity = $this->getDoctrine()->getRepository($parentClass)->find($parentId);
     if (!$this->get('oro_security.security_facade')->isGranted('VIEW', $parentEntity)) {
         throw new AccessDeniedException();
     }
     $accessor = PropertyAccess::createPropertyAccessor();
     $attachment = $accessor->getValue($parentEntity, $fieldName);
     if ($attachment instanceof Collection) {
         foreach ($attachment as $attachmentEntity) {
             if ($attachmentEntity->getOriginalFilename() === $filename) {
                 $attachment = $attachmentEntity;
                 break;
             }
         }
     }
     if ($attachment instanceof Collection || $attachment->getOriginalFilename() !== $filename) {
         throw new NotFoundHttpException();
     }
     $response = new Response();
     $response->headers->set('Cache-Control', 'public');
     if ($type == 'get') {
         $response->headers->set('Content-Type', $attachment->getMimeType() ?: 'application/force-download');
     } else {
         $response->headers->set('Content-Type', 'application/force-download');
         $response->headers->set('Content-Disposition', sprintf('attachment;filename="%s"', $attachment->getOriginalFilename()));
     }
     $response->headers->set('Content-Length', $attachment->getFileSize());
     $response->setContent($this->get('oro_attachment.manager')->getContent($attachment));
     return $response;
 }
Exemple #12
0
 /**
  * @dataProvider getSetDataProvider
  */
 public function testGetSet($property, $value)
 {
     $obj = new Call();
     $accessor = PropertyAccess::createPropertyAccessor();
     $accessor->setValue($obj, $property, $value);
     $this->assertSame($value, $accessor->getValue($obj, $property));
 }
 protected function setUp()
 {
     $this->context = $this->getMock('Symfony\\Component\\Validator\\ExecutionContext', array(), array(), '', false);
     $this->validator = new ExpressionValidator(PropertyAccess::createPropertyAccessor());
     $this->validator->initialize($this->context);
     $this->context->expects($this->any())->method('getClassName')->will($this->returnValue(__CLASS__));
 }
Exemple #14
0
 /**
  * @dataProvider propertiesDataProvider
  *
  * @param string $property
  * @param mixed  $value
  */
 public function testSettersAndGetters($property, $value)
 {
     $obj = new ConfigValue();
     $accessor = PropertyAccess::createPropertyAccessor();
     $accessor->setValue($obj, $property, $value);
     $this->assertSame($value, $accessor->getValue($obj, $property));
 }
 /**
  * @param object $object
  * @param string $propertyName
  */
 public function __construct($object, $propertyName)
 {
     $this->accessor = PropertyAccess::createPropertyAccessor();
     $this->object = $object;
     $this->propertyName = $propertyName;
     $this->findAdderAndRemover();
 }
 /**
  * Renders a pagerfanta.
  *
  * @param PagerfantaInterface $pagerfanta The pagerfanta.
  * @param string              $viewName   The view name.
  * @param array               $options    An array of options (optional).
  *
  * @return string The pagerfanta rendered.
  */
 public function renderPagerfanta(PagerfantaInterface $pagerfanta, $viewName = null, array $options = array())
 {
     $options = array_replace(array('routeName' => null, 'routeParams' => array(), 'pageParameter' => '[page]', 'queryString' => null), $options);
     if (null === $viewName) {
         $viewName = $this->container->getParameter('white_october_pagerfanta.default_view');
     }
     $router = $this->container->get('router');
     if (null === $options['routeName']) {
         $request = $this->container->get('request');
         $options['routeName'] = $request->attributes->get('_route');
         if ('_internal' === $options['routeName']) {
             throw new \Exception('PagerfantaBundle can not guess the route when used in a subrequest');
         }
         $options['routeParams'] = array_merge($request->query->all(), $request->attributes->get('_route_params'));
     }
     $routeName = $options['routeName'];
     $routeParams = $options['routeParams'];
     $pagePropertyPath = new PropertyPath($options['pageParameter']);
     $routeGenerator = function ($page) use($router, $routeName, $routeParams, $pagePropertyPath, $options) {
         $propertyAccessor = PropertyAccess::getPropertyAccessor();
         $propertyAccessor->setValue($routeParams, $pagePropertyPath, $page);
         $url = $router->generate($routeName, $routeParams);
         if ($options['queryString']) {
             $url .= '?' . $options['queryString'];
         }
         return $url;
     };
     return $this->container->get('white_october_pagerfanta.view_factory')->get($viewName)->render($pagerfanta, $routeGenerator, $options);
 }
Exemple #17
0
 public function __construct(Container $container)
 {
     $this->basePath = app_upload();
     $this->baseSource = app_upload() . '/uploads';
     $this->propertyAccessor = PropertyAccess::getPropertyAccessor();
     $this->basedirs = array();
 }
Exemple #18
0
 public function testProcess()
 {
     $item = ['property' => 'value'];
     $expectedProperty = 'property2';
     $expectedValue = 'value2';
     /** @var \PHPUnit_Framework_MockObject_MockObject|SerializerInterface $serializer */
     $serializer = $this->getMock('Symfony\\Component\\Serializer\\SerializerInterface');
     $serializer->expects($this->once())->method('deserialize')->will($this->returnCallback(function ($item) {
         return (object) $item;
     }));
     $this->processor->setSerializer($serializer);
     /** @var \PHPUnit_Framework_MockObject_MockObject|StrategyInterface $strategy */
     $strategy = $this->getMock('Oro\\Bundle\\ImportExportBundle\\Strategy\\StrategyInterface');
     $strategy->expects($this->once())->method('process')->with($this->isType('object'))->will($this->returnCallback(function ($item) use($expectedProperty, $expectedValue) {
         $item->{$expectedProperty} = $expectedValue;
         return $item;
     }));
     $this->processor->setStrategy($strategy);
     $this->processor->setEntityName('\\stdClass');
     /** @var \PHPUnit_Framework_MockObject_MockObject|ContextInterface $context */
     $context = $this->getMock('Oro\\Bundle\\ImportExportBundle\\Context\\ContextInterface');
     $context->expects($this->once())->method('getConfiguration')->will($this->returnValue([]));
     $this->processor->setImportExportContext($context);
     $result = $this->processor->process($item);
     $propertyAccessor = PropertyAccess::createPropertyAccessor();
     $this->assertNotEmpty($propertyAccessor->getValue($result, $expectedProperty), $expectedValue);
 }
Exemple #19
0
 /**
  * @return PropertyAccessor
  */
 protected static function getAccessotr()
 {
     if (is_null(static::$accessor)) {
         static::$accessor = PropertyAccess::createPropertyAccessor();
     }
     return static::$accessor;
 }
 public function testPropertyAccess()
 {
     $object = new AccessorHelper();
     $accessor = PropertyAccess::createPropertyAccessor();
     $accessor->setValue($object, 'name', 'test');
     $this->assertEquals('test', $accessor->getValue($object, 'name'));
 }
 /**
  * {@inheritdoc}
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $choiceList = function (Options $options) {
         return new ObjectChoiceList($options['option']->getValues(), 'value', array(), null, 'id', PropertyAccess::createPropertyAccessor());
     };
     $resolver->setDefaults(array('choice_list' => $choiceList))->setRequired(array('option'))->addAllowedTypes(array('option' => 'Sylius\\Component\\Variation\\Model\\OptionInterface'));
 }
Exemple #22
0
 public function getJobStatistics(Job $job)
 {
     $statisticData = array();
     $dataPerCharacteristic = array();
     $stmt = $this->em->getConnection()->prepare('SELECT * FROM jms_job_statistics WHERE job_id = :jobId');
     $stmt->execute(array('jobId' => $job->getId()));
     $statistics = $stmt->fetchAll();
     $propertyAccess = PropertyAccess::createPropertyAccessor();
     foreach ($statistics as $row) {
         $dataPerCharacteristic[$propertyAccess->getValue($row, '[characteristic]')][] = array($propertyAccess->getValue($row, '[createdAt]'), $propertyAccess->getValue($row, '[charValue]'));
     }
     if ($dataPerCharacteristic) {
         $statisticData = array(array_merge(array('Time'), $chars = array_keys($dataPerCharacteristic)));
         $startTime = strtotime($dataPerCharacteristic[$chars[0]][0][0]);
         $endTime = strtotime($dataPerCharacteristic[$chars[0]][count($dataPerCharacteristic[$chars[0]]) - 1][0]);
         $scaleFactor = $endTime - $startTime > 300 ? 1 / 60 : 1;
         // This assumes that we have the same number of rows for each characteristic.
         for ($i = 0, $c = count(reset($dataPerCharacteristic)); $i < $c; $i++) {
             $row = array((strtotime($dataPerCharacteristic[$chars[0]][$i][0]) - $startTime) * $scaleFactor);
             foreach ($chars as $name) {
                 $value = (double) $dataPerCharacteristic[$name][$i][1];
                 switch ($name) {
                     case 'memory':
                         $value /= 1024 * 1024;
                         break;
                 }
                 $row[] = $value;
             }
             $statisticData[] = $row;
         }
     }
     return $statisticData;
 }
 /**
  * {@inheritdoc}
  */
 public function getCommandFrom($className)
 {
     if (class_exists($className)) {
         $accessor = PropertyAccess::createPropertyAccessor();
         $reflector = new \ReflectionClass($className);
         $instance = $reflector->newInstanceWithoutConstructor();
         foreach ($reflector->getProperties() as $property) {
             if ($instance instanceof ConsoleCommandInterface && $property->getName() == 'io') {
                 continue;
             }
             if (!$this->format->hasArgument($property->getName()) && !$this->format->hasOption($property->getName())) {
                 throw new \InvalidArgumentException(sprintf("There is not '%s' argument defined in the %s command", $property->getName(), $className));
             }
             $value = null;
             if ($this->format->hasArgument($property->getName())) {
                 $value = $this->args->getArgument($property->getName());
             } elseif ($this->format->hasOption($property->getName())) {
                 $value = $this->args->getOption($property->getName());
             }
             $accessor->setValue($instance, $property->getName(), $value);
         }
         return $instance;
     }
     return;
 }
 /**
  * {@inheritdoc}
  */
 public function transform($model)
 {
     if (null === $model) {
         return null;
     }
     if (count($this->repository->getIdentifierProperties()) > 1) {
         throw new \InvalidArgumentException('Cannot transform object with multiple identifiers');
     }
     $identifierProperty = $this->repository->getIdentifierProperties()[0];
     $propertyAccessor = PropertyAccess::createPropertyAccessor();
     if ($this->multiple) {
         if (!is_array($model)) {
             throw new UnexpectedTypeException($model, 'array');
         }
         $identifiers = [];
         foreach ($model as $object) {
             $identifiers[] = $propertyAccessor->getValue($object, $identifierProperty);
         }
         return $identifiers;
     }
     if (!is_object($model)) {
         throw new UnexpectedTypeException($model, 'object');
     }
     return $propertyAccessor->getValue($model, $identifierProperty);
 }
Exemple #25
0
 /**
  * @param ResourceDefinitionInterface $resourceDefinition
  * @param array                       $parameters
  * @return string
  * @throws \Exception
  */
 public function generate(ResourceDefinitionInterface $resourceDefinition, array $parameters = array())
 {
     $definedParams = $resourceDefinition->getParameters();
     if (count($definedParams) < count($parameters)) {
         throw new \RuntimeException();
     }
     preg_match('/\\{([a-zA-Z.]+)\\}+/', $resourceDefinition->getPath(), $paramsInPath);
     $path = preg_replace_callback('/\\{([a-zA-Z.]+)\\}+/', function ($matches) use($parameters, $resourceDefinition, $paramsInPath) {
         if (strpos($matches[1], '.')) {
             $accessor = PropertyAccess::createPropertyAccessor();
             $path = explode('.', $matches[1]);
             $root = array_shift($path);
             $result = $accessor->getValue($parameters[$root], implode('.', $path));
             $paramsInPath[] = $root;
         } else {
             if (!array_key_exists($matches[1], $parameters)) {
                 throw new \RuntimeException(sprintf('Parameter `%s` is required in route `%s`, but was not passed', $matches[1], $resourceDefinition->getPath()));
             }
             $result = $parameters[$matches[1]];
             $paramsInPath[] = $matches[1];
         }
         return $result;
     }, $resourceDefinition->getPath());
     $leftovers = array_diff_key($definedParams, array_flip($paramsInPath));
     $leftoverValues = array_intersect_key($parameters, $leftovers);
     if ($leftoverValues) {
         $path .= '?' . http_build_query($leftoverValues);
     }
     return $path;
 }
 /**
  * @param FormEvent $event
  */
 public function buildCredentials(FormEvent $event)
 {
     /** @var array $data */
     $data = $event->getData();
     if (is_null($data)) {
         return;
     }
     $propertyPath = is_array($data) ? '[factoryName]' : 'factoryName';
     $factoryName = PropertyAccess::createPropertyAccessor()->getValue($data, $propertyPath);
     if (empty($factoryName)) {
         return;
     }
     $form = $event->getForm();
     $form->add('config', 'form');
     $configForm = $form->get('config');
     $gatewayFactory = $this->registry->getGatewayFactory($factoryName);
     $config = $gatewayFactory->createConfig();
     $propertyPath = is_array($data) ? '[config]' : 'config';
     $firstTime = false == PropertyAccess::createPropertyAccessor()->getValue($data, $propertyPath);
     foreach ($config['payum.default_options'] as $name => $value) {
         $propertyPath = is_array($data) ? "[config][{$name}]" : "config[{$name}]";
         if ($firstTime) {
             PropertyAccess::createPropertyAccessor()->setValue($data, $propertyPath, $value);
         }
         $type = is_bool($value) ? 'checkbox' : 'text';
         $options = array();
         $options['required'] = in_array($name, $config['payum.required_options']);
         $configForm->add($name, $type, $options);
     }
     $event->setData($data);
 }
Exemple #27
0
 /**
  * Add organization field to the search mapping
  *
  * @param PrepareEntityMapEvent $event
  */
 public function prepareEntityMapEvent(PrepareEntityMapEvent $event)
 {
     $data = $event->getData();
     $className = $event->getClassName();
     $entity = $event->getEntity();
     $organizationId = self::EMPTY_ORGANIZATION_ID;
     $metadata = $this->metadataProvider->getMetadata($className);
     if ($metadata) {
         $organizationField = null;
         if ($metadata->getGlobalOwnerFieldName()) {
             $organizationField = $metadata->getGlobalOwnerFieldName();
         }
         if ($metadata->isGlobalLevelOwned()) {
             $organizationField = $metadata->getOwnerFieldName();
         }
         if ($organizationField) {
             $propertyAccessor = PropertyAccess::createPropertyAccessor();
             /** @var Organization $organization */
             $organization = $propertyAccessor->getValue($entity, $organizationField);
             if ($organization && null !== $organization->getId()) {
                 $organizationId = $organization->getId();
             }
         }
     }
     $data['integer']['organization'] = $organizationId;
     $event->setData($data);
 }
Exemple #28
0
 /**
  * Sort the given array of arrays/objects using paths.
  *
  * e.g.
  *
  *      $data = array(
  *          array('foobar' => 'b'),
  *          array('foobar' => 'a'),
  *      );
  *
  *      SortUtils::multisort($data, '[foobar]', 'asc');
  *
  *      echo $data[0]; // "a"
  *
  * You can also use method names:
  *
  *      SortUtils::multisort($data, 'getFoobar', 'asc');
  *
  * Or sort on multidimensional arrays:
  *
  *      SortUtils::multisort($data, 'foobar.bar.getFoobar', 'asc');
  *
  * And you can sort on multiple paths:
  *
  *      SortUtils::multisort($data, array('foo', 'bar'), 'asc');
  *
  * The path is any path accepted by the property access component:
  *
  * @link http://symfony.com/doc/current/components/property_access/introduction.html
  *
  * @param array        $values
  * @param string|array $path      Path or paths on which to sort on
  * @param string       $direction Direction to sort in (either ASC or DESC)
  *
  * @return array
  */
 public static function multisort($values, $paths, $direction = 'ASC')
 {
     $accessor = PropertyAccess::createPropertyAccessor();
     $values = (array) $values;
     $paths = (array) $paths;
     usort($values, function ($a, $b) use($accessor, $paths) {
         foreach ($paths as $i => $path) {
             $aOrder = $accessor->getValue($a, $path);
             $bOrder = $accessor->getValue($b, $path);
             if (is_string($aOrder)) {
                 $aOrder = strtolower($aOrder);
                 $bOrder = strtolower($bOrder);
             }
             if ($aOrder == $bOrder) {
                 if (count($paths) == $i + 1) {
                     return 0;
                 } else {
                     continue;
                 }
             }
             return $aOrder < $bOrder ? -1 : 1;
         }
     });
     if (strtoupper($direction) == 'DESC') {
         $values = array_reverse($values);
     }
     return $values;
 }
 /**
  * Handle pre save event
  *
  * @param LifecycleEventArgs $args Event arguments
  */
 protected function preSave(LifecycleEventArgs $args)
 {
     $annotations = $this->container->get('cyber_app.metadata.reader')->getUploadebleFieldsAnnotations($args->getEntity());
     if (0 === count($annotations)) {
         return;
     }
     foreach ($annotations as $field => $annotation) {
         $config = $this->container->getParameter('oneup_uploader.config.' . $annotation->endpoint);
         if (!(isset($config['use_orphanage']) && $config['use_orphanage'])) {
             continue;
         }
         $value = (array) PropertyAccess::createPropertyAccessor()->getValue($args->getEntity(), $field);
         $value = array_filter($value, 'strlen');
         $value = array_map(function ($file) {
             return pathinfo($file, PATHINFO_BASENAME);
         }, $value);
         if (empty($value)) {
             continue;
         }
         $orphanageStorage = $this->container->get('oneup_uploader.orphanage.' . $annotation->endpoint);
         $files = [];
         foreach ($orphanageStorage->getFiles() as $file) {
             if (in_array($file->getBasename(), $value, true)) {
                 $files[] = $file;
             }
         }
         $orphanageStorage->uploadFiles($files);
     }
 }
Exemple #30
0
 /**
  * @param RFMAwareInterface $entity
  *
  * {@inheritdoc}
  */
 public function build(AnalyticsAwareInterface $entity)
 {
     $status = false;
     $channel = $entity->getDataChannel();
     if (!$channel) {
         return $status;
     }
     $data = $channel->getData();
     if (empty($data[RFMAwareInterface::RFM_STATE_KEY])) {
         return $status;
     }
     if (!filter_var($data[RFMAwareInterface::RFM_STATE_KEY], FILTER_VALIDATE_BOOLEAN)) {
         return $status;
     }
     $propertyAccessor = PropertyAccess::createPropertyAccessor();
     foreach ($this->providers as $provider) {
         if ($provider->supports($entity)) {
             $value = $provider->getValue($entity);
             $type = $provider->getType();
             $entityIndex = $propertyAccessor->getValue($entity, $type);
             $index = $this->getIndex($entity, $type, $value);
             if ($index === $entityIndex) {
                 continue;
             }
             $propertyAccessor->setValue($entity, $type, $index);
             $status = true;
         }
     }
     return $status;
 }