public function getParameter($parameter) { if (!$this->configs instanceof ArrayCollection) { $this->generateConfigs($file = 'parameters.yml', null, false); } return $this->configs->get($parameter); }
/** * Gets a MarkdownParserInterface of the specified name/alias. * * @param string $name The parser name * * @return MarkdownParserInterface */ public function getParser($name) { if ($this->hasParser($name) === false) { throw new \InvalidArgumentException(sprintf('The Markdown parser "%s" is not found.', $name)); } return $this->parsers->get($name); }
/** * @param string $name * * @return CacheItemPoolInterface * @throws RuntimeException */ public function getPool($name) : CacheItemPoolInterface { if (!$this->hasPool($name)) { throw new RuntimeException(sprintf('Could not find cache pool with name %s.', $name)); } return $this->pools->get($name); }
/** * Enable content provider by name. * * @param string $name * @return ContentProviderManager */ public function enableContentProvider($name) { if ($this->hasContentProvider($name)) { $this->contentProviders->get($name)->setEnabled(true); } return $this; }
/** * @param ImportRowProcess $item * @return bool|mixed|null */ protected function searchEntity(ImportRowProcess $item) { $rowKey = $item->getRowKey(); if (!isset($this->entityKeyByRowKey[md5($rowKey)])) { return false; } return $this->entityCollection->get($this->entityKeyByRowKey[md5($rowKey)]); }
/** * * @param string $key * @param string $section * @return \Doctrine\Common\Collections\ArrayCollection */ public function getDefault($key, $section = "default") { $data = null; if ($this->defaults->containsKey($section . '.' . $key)) { $data = $this->defaults->get($section . '.' . $key); } return $data; }
/** * @param ImportItemProcess $item * @return bool|mixed|null */ protected function searchEntity(ImportItemProcess $item) { $outerId = $item->getItemValue(); if (!isset($this->entityKeyByOuterId[$outerId])) { return false; } return $this->entityCollection->get($this->entityKeyByOuterId[$outerId]); }
/** * @param AbstractUser $user * @return string */ public function getAuditEntryFieldClass(AbstractUser $user) { $userClass = ClassUtils::getRealClass($user); if (!$this->entryFieldMap->containsKey($userClass)) { throw new \InvalidArgumentException(sprintf('Audit entry field not found for "%s"', $userClass)); } return $this->entryFieldMap->get($userClass); }
public function testGetNumbersForExistinUserWillReturn200ResponseWithNumbersList() { $this->client->request('GET', '/users/1/numbers'); $response = $this->client->getResponse(); $this->assertJsonResponse($response, 200); $numbers = new ArrayCollection($this->getContainer()->get('jms_serializer')->deserialize($response->getContent(), 'array<Arkon\\Bundle\\PhoneBookBundle\\Entity\\PhoneNumber>', 'json')); $this->assertSame(694984427, $numbers->get(0)->getNumber()); $this->assertSame(724489496, $numbers->get(1)->getNumber()); }
/** * @param ArrayCollection $data * @return Artice */ public function build(ArrayCollection $data) { $article = new Article(); $article->setTitle($data->get('title')); $article->setDescription($data->get('description')); $article->setUrl($data->get('url')); $article->setFeed($data->get('feed')); $article->onPrePersist(); return $article; }
/** * @param DiamanteUser|null $user * * @return string */ public function getAuditEntryFieldClass(DiamanteUser $user = null) { if ($user === null) { return $this->entryFieldMap->first(); } $userClass = ClassUtils::getRealClass($user); if (!$this->entryFieldMap->containsKey($userClass)) { throw new \InvalidArgumentException(sprintf('Audit entry field not found for "%s"', $userClass)); } return $this->entryFieldMap->get($userClass); }
/** * @inheritdoc */ public function find(Uuid $uuid) { return $this->collection->get((string) $uuid); /* $criteria = Criteria::create()->where(Criteria::expr()->in('id', [$uuid])); $result = $this->collection->matching($criteria); if ($result->count()) { return $result->first(); } return null;*/ }
/** * Return the last oxford comma eligible word * in the sentence * * @return ArrayCollection|Word[] */ public function getOxfordItems() { $words = new ArrayCollection(); $conjunctions = $this->words->filter(function (Word $word) { return $word instanceof Conjunction; }); $conjunctions->map(function ($word) use($words) { if ($this->hasOxfordable($word)) { $index = $this->words->indexOf($word) - 1; $words->add($this->words->get($index)); } }); return $words; }
/** * @param BundleInterface $bundle * @param string $entity * @param ClassMetadataInfo $metadata * @param ArrayCollection $options * * @throws \RuntimeException */ public function generate(BundleInterface $bundle, $entity, ClassMetadataInfo $metadata, ArrayCollection $options = null) { $this->routePrefix = $options->get('route-prefix'); $this->routeNamePrefix = str_replace('/', '_', $options->get('route-prefix')); $this->actions = ['getById', 'getAll', 'post', 'put', 'delete']; if (count($metadata->identifier) > 1) { throw new \RuntimeException('The REST Controller generator does not support entity classes with multiple primary keys.'); } $this->entity = $entity; $this->bundle = $bundle; $this->metadata = $metadata; $this->setFormat('yml'); $this->generateControllerClass($options->get('overwrite'), $options->get('document'), $options->get('resource'), $metadata); }
/** * Get parameter. * * @param string $parameter * @param mixed $default * * @return mixed */ public function getParameter($parameter, $default = null) { if (!$this->parameters instanceof ArrayCollection) { return $default; } return $this->parameters->containsKey($parameter) ? $this->parameters->get($parameter) : $default; }
/** * Magic attribute getter * * @param string $method * @param array $args * @return string */ public function __call($method, $args) { if (substr($method, 0, 3) === 'get') { $key = $this->underscore(substr($method, 3)); return $this->attributes->get($key); } }
public function get($key) { if (null === $this->entries) { $this->__load___(); } return $this->entries->get($key); }
/** * @param ArrayCollection $data * @param ArrayCollection $expected * * @dataProvider provideFields */ public function testReverseTransform($data, ArrayCollection $expected) { $fields = $this->transformer->reverseTransform($data); foreach ($fields as $key => $field) { $this->assertSame($field, $expected->get($key)); } }
/** * @param string $providerAlias */ public function startProviderEmulation($providerAlias) { if (!$this->providers->containsKey($providerAlias)) { throw new \InvalidArgumentException(sprintf('Provider with "%s" alias not registered', $providerAlias)); } $this->emulatedProvider = $this->providers->get($providerAlias); }
/** * Get preview image * * @return Image */ public function getPreviewImage() { if ($this->images->containsKey($this->previewImageKey)) { return $this->images->get($this->previewImageKey); } return $this->images->first(); }
/** * Get a Key/Value position by Key, if it exists - returns false if the * key does not exist * * @param mixed $key The key to search the index for * * @return integer|bool */ private function getPosition($key) { if ($this->index->containsKey($key)) { return $this->index->get($key); } return false; }
/** * @param $searchFilter * @return array */ protected function getFieldsFromFilterName($searchFilter) { $fields = $this->filters->get($searchFilter)->getFields(); if (is_string($fields)) { $fields = [$fields]; } return $fields; }
/** * @param $name * @param Command $command * @param $arguments * @param $priority */ public function addCommand($name, Command $command, $arguments, $priority) { if (!$this->commands->containsKey($name)) { $this->commands->set($name, new ArrayCollection()); } $meta = new CommandMeta($command, $arguments, $priority); $this->commands->get($name)->add($meta); }
/** * Entity errors getter * * @param string $key * @return ArrayCollection|mixed|null */ public function getEntityErrors($key) { $errors = $this->errors->get($key); if (is_null($errors)) { $errors = new ArrayCollection(); } return $errors; }
/** * Generates the entity form class if it does not exist. * * @param BundleInterface $bundle The bundle in which to create the class * @param string $entity The entity relative class name * @param ClassMetadataInfo $metadata The entity metadata class * @param ArrayCollection $options [restSupport => (bool)] */ public function generate(BundleInterface $bundle, $entity, ClassMetadataInfo $metadata, ArrayCollection $options = null) { $dir = $bundle->getPath(); $parts = explode('\\', $entity); $entityClass = array_pop($parts); $entityNamespace = implode('\\', $parts); $this->setGeneratedName($entityClass . "Handler.php"); $target = sprintf('%s/Handler/%sHandler.php', $dir, $entityClass); $this->setFilePath($target); if (!is_dir(dirname($target))) { mkdir(dirname($target)); } if (!$options->get('overwrite') && file_exists($target)) { throw new \RuntimeException(sprintf('Unable to generate the handler class %s as it already exists.', $target)); } $this->renderFile('handler/handler.php.twig', $target, ['entity' => $entity, 'entity_class' => $entityClass, 'namespace' => $bundle->getNamespace(), 'entity_namespace' => $entityNamespace], $options->get('overwrite')); $this->declareService($bundle, $entity); }
/** * Drops a Collection - removing all data * * @param string $collection The name of the Collection to drop */ public function drop($collection) { if (!$this->collections->containsKey($collection)) { return false; } $this->collections->get($collection)->drop(); $this->collections->remove($collection); return true; }
public function addItem(Item $item) { $inventario = new Inventario(); $inventario->setItem($item); $inventario->setUsuario($this); $key = false; foreach ($this->inventario as $k => $i) { if ($i->getItem()->getId() == $item->getId()) { var_dump($key = $k); break; } } if ($key === false) { $this->inventario->add($inventario); } else { $inventario = $this->inventario->get($key); $inventario->addQuantidade(1); } }
/** * Set Snippet Data to the appropriate fields * * @param string $fieldName the name of the SnippetField * @param string $fieldData the data of the SnippetField * * @return Newscoop\Entity\Snippet */ public function setData($fieldName, $fieldData = null) { if ($this->fields->containsKey($fieldName)) { $this->fields->get($fieldName)->setData($fieldData); } else { throw new \Exception('Snippet: "' . $this->name . '" does not have Field: "' . $fieldName . '"'); } $this->setModified(); return $this; }
/** * @param ArrayCollection $articles * @param Integer $batch_size */ public function bulkInserts(ArrayCollection $articles, $batch_size = 20) { $length = $articles->count(); for ($i = 1; $i < $length; ++$i) { $this->merge($articles->get($i)); if (0 === $i % $batch_size) { $this->detaches(); } } $this->detaches(); }
/** * Return registered database under given name * * @param string $connectionName * * @return \OrientDB */ public function getDatabase($connectionName = 'default') { if ($this->databases->containsKey($connectionName)) { return $this->databases->get($connectionName); } $configuration = $this->getConfiguration($connectionName); $database = $this->getConnection($connectionName); $database->DBOpen($configuration->getDatabase(), $configuration->getUser(), $configuration->getPassword()); $this->databases->set($connectionName, $database); return $this->databases->get($connectionName); }