containsKey() public method

{@inheritDoc}
public containsKey ( $key )
 /**
  * @param string $name
  *
  * @return Blog|null
  */
 public function find($name)
 {
     if ($this->blogs->containsKey($name)) {
         return $this->blogs[$name];
     }
     return null;
 }
Example #2
0
 /**
  * @param string $class
  * @return ColumnTypeInterface
  */
 public function getType(string $class)
 {
     if ($this->types->containsKey($class)) {
         return $this->types[$class];
     }
     return null;
 }
 /**
  * @inheritdoc
  */
 public function remove(User $user)
 {
     if (!$this->collection->containsKey((string) $user->getId())) {
         throw new UserNotFoundException();
     }
     return $this->collection->removeElement($user);
 }
Example #4
0
 public function addModel(BaseModel $model)
 {
     if (!$this->models->containsKey($model->name)) {
         $model->bundle = $this;
         $this->models->set($model->name, $model);
     }
     return $this;
 }
Example #5
0
 public function addBundle(BaseBundle $bundle)
 {
     if (!$this->bundles->containsKey($bundle->name)) {
         $bundle->map = $this;
         $this->bundles->set($bundle->name, $bundle);
     }
     return $this;
 }
Example #6
0
 /**
  * @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);
 }
Example #7
0
 /**
  *
  * @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;
 }
Example #8
0
 /**
  * @param BlogId $id
  *
  * @return Blog|null
  */
 public function find(BlogId $id)
 {
     $key = (string) $id;
     if (!$this->storage->containsKey($key)) {
         return null;
     }
     return $this->storage[$key];
 }
Example #9
0
 /**
  * Set registered types
  *
  * @param string               $typeName
  * @param IntegrationInterface $type
  *
  * @throws \LogicException
  * @return $this
  */
 public function addChannelType($typeName, IntegrationInterface $type)
 {
     if (!$this->integrationTypes->containsKey($typeName)) {
         $this->integrationTypes->set($typeName, $type);
     } else {
         throw new LogicException(sprintf('Trying to redeclare integration type "%s".', $typeName));
     }
     return $this;
 }
 /**
  * Add activity
  *
  * @param Activity $activity
  * @return Student
  */
 public function addActivity(Activity $activity)
 {
     $key = $activity->getMachineName();
     if ($this->activities->containsKey($key)) {
         throw new \InvalidArgumentException('This Student already belongs to this Activity');
     }
     $this->activities->set($key, $activity);
     return $this;
 }
 /**
  * @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);
 }
Example #12
0
 /**
  * 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;
 }
Example #13
0
 /**
  * Get preview image
  *
  * @return Image
  */
 public function getPreviewImage()
 {
     if ($this->images->containsKey($this->previewImageKey)) {
         return $this->images->get($this->previewImageKey);
     }
     return $this->images->first();
 }
Example #14
0
 /**
  * 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;
 }
 /**
  * @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);
 }
Example #16
0
 static function load(Config $config)
 {
     $scenes = new ArrayCollection();
     // Start with the entry scene
     $stack = array();
     $scene = $config['entry_scene'];
     array_push($stack, $scene);
     // Loop until our stack is empty
     while (count($stack)) {
         // Load a scene from the stack
         $scenePath = array_pop($stack);
         $data = Yaml::load($config['base_directory'] . '/' . $scenePath . '.yml');
         // Create a scene from the data
         $newScene = new Scene($scenePath, $data);
         $scenes->set($scenePath, $newScene);
         // If we have exit-scenes, add them to the stack so we can load them
         foreach ($data['scene']['exit'] as $direction => $exitScene) {
             $tmp['exit'][strtolower($direction)] = $exitScene;
             // Only add to stack when we haven't already processed that scene
             if (!$scenes->containsKey($exitScene)) {
                 array_push($stack, $exitScene);
             }
         }
     }
     return $scenes;
 }
Example #17
0
 public function addKey($name, $value)
 {
     if (!$this->keys->containsKey($name)) {
         $this->keys->set($name, $value);
     }
     return $this;
 }
 public function containsKey($key)
 {
     if (null === $this->entries) {
         $this->__load___();
     }
     return $this->entries->containsKey($key);
 }
Example #19
0
 /**
  * @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);
 }
Example #20
0
 /**
  * Add primary detail.
  *
  * @param PrimaryContactDetail $detail
  *
  * @return Contact
  */
 public function setPrimaryDetails(PrimaryContactDetail $detail)
 {
     if (!$this->primaryDetails->containsKey($detail->getType()->getId())) {
         $this->primaryDetails->add($detail);
     }
     $detail->setContact($this);
     return $this;
 }
 /**
  * Tests IdentityWrapper->containsKey()
  */
 public function testContainsKey()
 {
     foreach (array_keys($this->entries) as $key) {
         $this->assertTrue($this->identityWrapper->containsKey($key));
         $this->assertFalse($this->wrappedCollection->containsKey($key));
     }
     $this->assertFalse($this->identityWrapper->contains('non-existent'));
 }
Example #22
0
 /**
  * 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;
 }
 /**
  * Add student
  *
  * @param Student $student
  *
  * @return Activity
  */
 public function addStudent(Student $student)
 {
     $key = $student->getId();
     if ($this->students->containsKey($key)) {
         throw new \InvalidArgumentException('The Student has already joined this Activity');
     }
     $this->students->set($key, $student);
     return $this;
 }
 /**
  * @param Skill $skill
  * @return Activity
  */
 public function addSkill(Skill $skill)
 {
     $key = $skill->getMachineName();
     if ($this->skills->containsKey($key)) {
         throw new \InvalidArgumentException('This Category already has a skill of that name');
     }
     $this->skills->set($key, $skill);
     return $this;
 }
Example #25
0
 /**
  * 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;
 }
Example #26
0
 /**
  * Guestimate the title field of the model.
  *
  * @return mixed
  */
 function titleField()
 {
     $keys = ['title', 'name', 'host', 'url', 'email'];
     foreach ($keys as $key) {
         if ($this->fields->containsKey($key)) {
             return $key;
         }
     }
     return $this->fields->first()->name;
 }
 /**
  * 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);
 }
 /**
  * @param      $className
  * @param null $fieldName
  * @return null|bool|AbstractConfigModel
  */
 public function findModel($className, $fieldName = null)
 {
     if (in_array($className, $this->ignoreModel)) {
         return false;
     }
     $cacheKey = $className . $fieldName;
     if ($this->localCache->containsKey($cacheKey)) {
         return $this->localCache->get($cacheKey);
     }
     $entityConfigModelRepo = $this->getEntityManager()->getRepository(EntityConfigModel::ENTITY_NAME);
     $entity = $entityConfigModelRepo->findOneBy(array('className' => $className));
     if ($fieldName) {
         $fieldConfigModelRepo = $this->getEntityManager()->getRepository(FieldConfigModel::ENTITY_NAME);
         $result = $fieldConfigModelRepo->findOneBy(array('entity' => $entity, 'fieldName' => $fieldName));
     } else {
         $result = $entity;
     }
     $this->localCache->set($cacheKey, $result);
     return $result;
 }
Example #29
0
 /**
  * Create new translation object
  *
  * @return TranslationInterface
  */
 protected function createTranslation()
 {
     $locale = $this->getLocale();
     if ($this->translations->containsKey($locale)) {
         return $this->translations->get($locale);
     }
     if (!isset($this->translationClassName)) {
         throw new InvalidArgumentException('Translation class name is required to create new translation instances');
     }
     $translation = new $this->translationClassName();
     $translation->setObject($this);
     $translation->setLocale($locale);
     $this->setTranslation($translation);
     return $translation;
 }
 /**
  * @param string $identifier
  * @return AbstractAddress
  */
 public function getEntityByIdentifier($identifier)
 {
     $identifierData = explode(self::DELIMITER, $identifier);
     if (empty($identifierData[1]) || !empty($identifierData[2])) {
         throw new \InvalidArgumentException(sprintf('Wrong identifier "%s"', $identifier));
     }
     $id = $identifierData[1];
     if (!filter_var($id, FILTER_VALIDATE_INT)) {
         throw new \InvalidArgumentException(sprintf('Wrong entity id "%s"', $id));
     }
     $alias = $identifierData[0];
     if (!$alias || !$this->map->containsKey($alias)) {
         throw new \InvalidArgumentException(sprintf('Unknown alias "%s"', $alias));
     }
     $className = $this->map->get($alias);
     return $this->registry->getManagerForClass($className)->find($className, (int) $id);
 }