Instantiate a contact object.

@param AnConfig $data The request data

@return AnObject
760051
protected function _instantiateContact($data)
    {
        $data->append(array(
            'contact' => new AnConfig(),
        ));

        $contact = new AnObject();
        $contact->set(array(
            'address' => $data->contact->address,
            'city' => $data->contact->city,
            'country' => $data->contact->country,
            'state' => $data->contact->state,
            'zip' => $data->contact->zip,
        ));

        $this->contact = $contact;

        return $contact;
    }
836915
public function setMainAccount(Contact $contact, $data)
    {
        // set account relation
        if (isset($data['account']) &&
            isset($data['account']['id']) &&
            'null' != $data['account']['id']
        ) {
            $accountId = $data['account']['id'];

            $account = $this->accountRepository->findAccountById($accountId);

            if (!$account) {
                throw new EntityNotFoundException($this->accountRepository->getClassName(), $accountId);
            }

            // get position
            $position = null;
            if (isset($data['position'])) {
                $position = $this->getPosition($data['position']);
            }

            // check if relation between account and contact already exists
            $mainAccountContact = $this->getMainAccountContact($contact);
            $accountContact = $this->getAccounContact($account, $contact);

            // remove previous main accountContact
            if ($mainAccountContact && $mainAccountContact !== $accountContact) {
                // if this contact is the main-Contact - set mainContact to null
                if ($mainAccountContact->getAccount()->getMainContact() === $contact) {
                    $mainAccountContact->getAccount()->setMainContact(null);
                }
                $this->em->remove($mainAccountContact);
            }

            // if account-contact relation existed set params
            if ($accountContact) {
                $accountContact->setMain(true);
                $accountContact->setPosition($position);
            } else {
                // else create new one
                $this->createMainAccountContact($contact, $account, $position);
            }
        } else {
            // if a main account exists - remove it
            if ($accountContact = $this->getMainAccountContact($contact)) {
                // if this contact is the main-Contact - set mainContact to null
                if ($accountContact->getAccount()->getMainContact() === $contact) {
                    $accountContact->getAccount()->setMainContact(null);
                }

                $this->em->remove($accountContact);
            }
        }
    }
99271
protected function createNewInstance(array $data): object
    {
        $instance = self::getInstantiator()->instantiate($this->getEntityClass());

        $refl = $this->getReflection();

        foreach ($data as $key => $value) {
            $prop = $refl->getProperty($key);
            $prop->setAccessible(true);

            if ($value instanceof Closure) {
                $value = $value($instance, $this, $this->manager);
            }

            $prop->setValue($instance, $value);
        }

        return $instance;
    }
863115
public function create($data, $contactId = null)
    {
        if (isset($contactId)) {
            return $this->client()->put($data, 'contacts/{contactId}', ['contactId' => $contactId]);
        }

        return $this->client()->post($data, 'contacts');
    }
388000
public function withData($data): self
    {
        $new = clone $this;
        $new->data = $data instanceof MessageData ? $data : MessageData::fromArray($data);

        return $new;
    }
1280634
public function create($data)
    {
        $descriptor = new MethodDescriptor($data->getName());
        $descriptor->setDescription($data->getDescription());
        $descriptor->setMethodName($data->getMethodName());

        $response = new ReturnDescriptor('return');
        $response->setTypes($this->builder->buildDescriptor(new Collection($data->getTypes())));
        $descriptor->setResponse($response);

        foreach ($data->getArguments() as $argument) {
            $argumentDescriptor = $this->createArgumentDescriptorForMagicMethod($argument);
            $descriptor->getArguments()->set($argumentDescriptor->getName(), $argumentDescriptor);
        }

        return $descriptor;
    }
1087838
public function create($data)
    {
        $constantDescriptor = new ConstantDescriptor();
        $constantDescriptor->setName($data->getShortName());
        $constantDescriptor->setValue($data->getValue());
        // Reflection library formulates namespace as global but this is not wanted for phpDocumentor itself
        $constantDescriptor->setNamespace(
            '\\' . (strtolower($data->getNamespace()) == 'global' ? '' :$data->getNamespace())
        );
        $constantDescriptor->setFullyQualifiedStructuralElementName(
            (trim($constantDescriptor->getNamespace(), '\\') ? $constantDescriptor->getNamespace() : '')
            . '\\' . $data->getShortName()
        );

        $this->assembleDocBlock($data->getDocBlock(), $constantDescriptor);

        $constantDescriptor->setLine($data->getLinenumber());

        return $constantDescriptor;
    }
1200971
public static function getInstance($config = null)
    {
        static $instance;

        $instance = $instance ? clone $instance : new self();

        if (!$config) {
            $config = new AnConfig();
        }

        $config->append(array(
            'date' => gmdate('Y-m-d H:i:s'),
        ));

        $instance->setDate($config->date);

        return $instance;
    }
303013
public function make($data)
    {
        if ($data instanceof Collection) {
            $this->data = collect($data->toArray());
        } elseif (is_array($data)) {
            $this->data = collect($data);
        } else {
            throw new InvalidArgumentException('Invalid data type.');
        }

        $this->config = Config::get('nestable');

        $this->parent = $this->config['parent'];

        $this->primary_key = $this->config['primary_key'];

        return $this;
    }
666602
protected function _initialize(AnConfig $config)
    {
        $child = clone $this->_parent;

        $child->name = AnInflector::singularize($config->name);

        $config->append(array(
            'entityset' => 'anahita:domain.entityset.onetomany',
            'cardinality' => 'many',
            'child_key' => $this->_parent->name,
            'parent_delete' => AnDomain::DELETE_CASCADE,
            'child' => $child,
        ));

        parent::_initialize($config);
    }
884497
protected function _initialize(AnConfig $config)
    {
        $repoIdentifier = $config->mixer->getIdentifier()->identifier;
        $config->append(array(
            'relationships' => array(
                'mentions' => array(
                    'through' => 'com:people.domain.entity.mention',
                    'target' => str_replace('repository', 'entity', $repoIdentifier),
                    'child_key' => 'tagable',
                    'target_child_key' => 'mention',
                    'inverse' => true,
                ),
            ),
        ));

        parent::_initialize($config);
    }
1299643
public function create($data)
    {
        $traitDescriptor = new TraitDescriptor();

        $traitDescriptor->setFullyQualifiedStructuralElementName($data->getFqsen());
        $traitDescriptor->setName($data->getName());
        $traitDescriptor->setLine($data->getLocation()->getLineNumber());
        $traitDescriptor->setPackage($this->extractPackageFromDocBlock($data->getDocBlock()) ?: '');

        // Reflection library formulates namespace as global but this is not wanted for phpDocumentor itself
        $traitDescriptor->setNamespace(
            substr((string) $data->getFqsen(), 0, -strlen($data->getName()) - 1)
        );

        $this->assembleDocBlock($data->getDocBlock(), $traitDescriptor);

        $this->addProperties($data->getProperties(), $traitDescriptor);
        $this->addMethods($data->getMethods(), $traitDescriptor);

        return $traitDescriptor;
    }
1060326
public function create($data)
    {
        $request = $this->getRequest();
        $response = $this->getResponse();
        $storyTellingService = $this->getStorytellingService();
        $domainService = $this->getDomainService();
        $user = null;
        
        $data = $this->fromJson();
        $storyMappingId = $data['story_mapping_id'];
        $storyMapping = $domainService->getStoryMappingMapper()->findById($storyMappingId);
        
        if (! $storyMapping) {
            $content = array(
                'result' => array(
                    'message' => 'Story missing',
                    'success' => false,
                    'data' => null,
                ),
            );
            
            $response->setContent($adapter->serialize($content));
            return $response;
        }

        $domain = $this->getDomainService()->getDomain($this);

        $storyTelling = new \PlaygroundFlow\Entity\OpenGraphStoryTelling();
        
        $storyTelling->setObject(json_encode($data['objects']))
            ->setPoints($storyMapping->getPoints())
            ->setSecretKey(null);

        if (!empty($data['user']['email'])) {
            // J'ai un user qui est identifié : user playground
            $user = $this->getUserService()->findUserOrCreateByEmail($data['user']['email']);
        
            // Association prospect - user si c'etait un prospect avant
            $prospect = $this->getProspectService()->getProspectMapper()->findOneBy(array('prospect' => $data['user']['anonymous']));
            if (!empty($prospect)) {
                if ($prospect->getUser() == null) {
                    $prospect->setUser($user);
                    $prospect = $this->getProspectService()->getProspectMapper()->update($prospect);
                }
                $storyTelling->setProspect($prospect);
            }
            $userDomain = $this->getUserDomainService()->findUserDomainOrCreateByUserAndDomain($user, $domain);
            // Association story telling à un utilisateur
            $storyTelling->setUser($user);
        } elseif (!empty($data['user']['anonymous'])) {
            // J'ai un anonymous
            $prospect = $this->getProspectService()->findProspectOrCreateByProspectAndDomain($data['user']['anonymous'], $domain);
            // Association story telling à un prospect
            $storyTelling->setProspect($prospect);
        }
        
        $storyTelling->setOpenGraphStoryMapping($storyMapping);
        // Creation de la storyTelling
        $storyTellingService->getStoryTellingMapper()->insert($storyTelling);

        // Si il y a un user, on met a jour son classement
        if (!empty($user)) {
            $this->getLeaderboardService()->addPoints($storyMapping, $user);
        }

        $storyTellingService->tellStory($storyTelling);
        
        $this->getEventManager()->trigger('story.'.$storyMapping->getId(), $this, array('storyTelling' => $storyTelling));
        
        $contentType = 'application/json';
        $adapter = '\Zend\Serializer\Adapter\Json';
        $response->getHeaders()->addHeaderLine('Content-Type', $contentType);
        $adapter = new $adapter;
        
        $data = $this->fromJson();
        $content = array(
            'result' => array(
                'message' => 'Post detected',
                'success' => true,
                'data' => $data['objects'],
            ),
        );
        
        $response->setContent($adapter->serialize($content));
        
        return $response;
    }
1165327
public static function create($data)
    {
        if (!$data) {
            return new self(self::COLLECTION_NAME);
        }

        $type = null;
        if (isset($data[self::COLLECTION_NAME])) {
            $type = self::COLLECTION_NAME;
        } elseif (isset($data[self::CONDITION_NAME])) {
            $type = self::CONDITION_NAME;
        }
        if (null === $type) {
            throw new ContainerException(
                sprintf('Invalid container type. Use %s', implode(' or ', self::ALLOWED_TYPES))
            );
        }
        if (!is_array($data[$type])) {
            throw new ContainerException(sprintf('Parameter "%s" must be array', $type));
        }
        /** @var Container $mainContainer */
        $mainContainer = new self($type);
        if (isset($data[self::AND_OR_OPERATOR_NAME])) {
            $mainContainer->setAndOr($data[self::AND_OR_OPERATOR_NAME]);
        }
        if (self::COLLECTION_NAME === $type) {
            foreach ($data[$type] as $datum) {
                $mainContainer->addToCollection(self::create($datum));
            }
        } elseif (self::CONDITION_NAME === $type) {
            $mainContainer->getCondition()->setData($data[$type]);
        }

        return $mainContainer;
    }
788972
public function create(Contact $contact): Contact
    {
        $response = $this->client->post($this->prepareUrlForKey('add-contact'), [], $contact->jsonSerialize());
        $responseData = $response->getDecodedBody();

        return new Contact($responseData);
    }
314285
public static function factory(Collection $data)
    {
        $instance = new static();

        $instance->id = (string) Uuid::uuid4();

        $instance->name = $data['name'];

        $instance->slug = str_slug($data['name']);

        $instance->graphEnabled = isset($data['graph_enabled'])
            ? $data['graph_enabled']
            : null;

        $instance->abbreviation = $data['abbreviation'];

        $instance->targets = $instance->instantiateTargets(
            $data['targets'] ?? collect()
        );

        $instance->notify =
            $data['notify'] ?? config('health.notifications.enabled');

        $instance->style = $instance->keysToCamel(config('health.style'));

        $instance->style['columnSize'] =
            $data['column_size'] ?? $instance->style['columnSize'];

        $instance->errorMessage =
            $data['error_message'] ?? config('health.errors.message');

        $instance->isGlobal = $data['is_global'] ?? false;

        $instance->checker = $instance->instantiateChecker($data['checker']);

        $instance->importProperties($data);

        return $instance;
    }
587604
protected function _initialize(AnConfig $config)
    {
        $base_url = AnRequest::base();
        $settings = $this->getService('com:settings.setting');

        if (PHP_SAPI == 'cli' && $settings->live_site != '') {
            $scheme = is_ssl() ? 'https://' : 'http://';
            $base_url = $scheme.$settings->live_site;
        }

        $config->append(array(
            'base_url' => $base_url,
            'test_options' => array(
                'enabled' => get_config_value('mailer.debug', false),
                'email' => get_config_value('mailer.redirect_email'),
                'log' => $settings->tmp_path . '/emails/',
            ),
            'template_view' => null,
        ));

        parent::_initialize($config);
    }