Exemplo n.º 1
0
 /**
  * Returns the scheme info for the given id
  *
  * @param string $id
  * @return SecurityScheme
  */
 public function get($id)
 {
     if (!$this->schemes->has($id)) {
         $this->schemes->set($id, new SecurityScheme($id));
     }
     return $this->schemes->get($id);
 }
Exemplo n.º 2
0
 /**
  * Returns the path info for the given path
  *
  * @param string $path
  * @return Path
  */
 public function get($path)
 {
     if (!$this->paths->has($path)) {
         $this->paths->set($path, new Path($path));
     }
     return $this->paths->get($path);
 }
Exemplo n.º 3
0
 /**
  * Returns the scopes for the given id
  *
  * @param string $id
  * @return Set
  */
 public function get($id)
 {
     if (!$this->securities->has($id)) {
         $this->securities->set($id, new Set());
     }
     return $this->securities->get($id);
 }
Exemplo n.º 4
0
 /**
  * Returns the reponse info for the given code
  *
  * @param string $code
  * @return Response
  */
 public function get($code)
 {
     if (!$this->responses->has($code)) {
         $this->responses->set($code, new Response($code));
     }
     return $this->responses->get($code);
 }
Exemplo n.º 5
0
 /**
  * Returns a set of allowed action ids
  *
  * @param User $user
  * @return Set
  */
 private function getPermissionTable(User $user)
 {
     $userId = $user->getId();
     if ($this->permissionTable->has($userId)) {
         return $this->permissionTable->get($userId);
     }
     // always allow what guests can do
     $guestGroup = GroupQuery::create()->findOneByIsGuest(true);
     // collect groups from user
     $groups = GroupQuery::create()->filterByUser($user)->find();
     $userGroup = GroupQuery::create()->filterByOwnerId($userId)->findOne();
     if ($userGroup) {
         $groups[] = $userGroup;
     }
     $groups[] = $guestGroup;
     // ... structure them
     $permissionTable = new Set();
     foreach ($groups as $group) {
         foreach ($group->getActions() as $action) {
             $permissionTable->add($action->getId());
         }
     }
     $this->permissionTable->set($userId, $permissionTable);
     return $this->permissionTable->get($userId);
 }
Exemplo n.º 6
0
 /**
  * @param Skill $skill
  * @return Skill[]
  */
 private function getDescendents(Skill $skill)
 {
     if (!$this->descendents->has($skill->getId())) {
         $this->descendents->set($skill->getId(), $skill->getDescendents());
     }
     return $this->descendents->get($skill->getId());
 }
Exemplo n.º 7
0
 /**
  *
  * @param string $packageName
  * @return CompletePackage
  */
 public function getComposerPackage($packageName)
 {
     if ($this->composerCache->has($packageName)) {
         return $this->composerCache->get($packageName);
     }
     $package = $this->loader->load($this->getJson($this->getFile($packageName)));
     $this->composerCache->set($packageName, $package);
     return $package;
 }
Exemplo n.º 8
0
 /**
  * Returns the extension for the given key by a given packageName
  *
  * @param string $key
  * @param string $packageName
  * @return ArrayList
  */
 public function getExtensionsByPackage($key, $packageName)
 {
     if ($this->packages->has($packageName)) {
         $pkg = $this->packages->get($packageName);
         if ($pkg->has($key)) {
             return $pkg->get($key);
         }
     }
     return [];
 }
Exemplo n.º 9
0
 protected function parse($contents)
 {
     $data = new Map($contents);
     if ($data->has('app')) {
         $this->app = new AppSchema($this->package, $data->get('app'));
     }
     if ($data->has('module')) {
         $this->module = new ModuleSchema($this->package, $data->get('module'));
     }
 }
Exemplo n.º 10
0
 /**
  * 
  */
 public function import($data, Event $event)
 {
     $csv = Reader::createFromString(trim($data));
     $csv->setDelimiter(';');
     // get startgroups at first
     $groups = new Map();
     foreach ($csv->fetchColumn(0) as $name) {
         if (!$groups->has($name)) {
             $startgroup = $this->getStartgroup($name);
             $startgroup->setEvent($event);
             $groups->set($name, $startgroup);
         }
     }
     $id = 0;
     foreach ($csv as $row) {
         $id++;
         $routine = $this->getRoutine($id);
         $group = $groups->get($row[0]);
         $judges = (count($row) - 1) / 3;
         for ($j = 1; $j <= $judges; $j++) {
             $score = new PerformanceScore();
             $score->setRoutine($routine);
             $score->setJudge($group->getPerformanceJudge($j));
             $score->setExecution($row[($j - 1) * 3 + 1]);
             $score->setChoreography($row[($j - 1) * 3 + 2]);
             $score->setMusicAndTiming($row[($j - 1) * 3 + 3]);
             $score->setTotal($row[($j - 1) * 3 + 1] + $row[($j - 1) * 3 + 2] + $row[($j - 1) * 3 + 3]);
             $routine->addPerformanceScore($score);
         }
         $group->addRoutine($routine);
         $group->save();
     }
     $event->save();
 }
Exemplo n.º 11
0
 /**
  * Loads a module and returns the associated class or returns if already loaded
  *
  * @param String $packageName
  * @throws ModuleException
  * @return AbstractModule
  */
 public function load($packageName)
 {
     if ($this->loadedModules->has($packageName)) {
         return $this->loadedModules->get($packageName);
     }
     // check existence
     if (!$this->installedModules->has($packageName)) {
         throw new ModuleException(sprintf('Module (%s) does not exist.', $packageName), 500);
     }
     // check activation
     if (!$this->activatedModules->has($packageName)) {
         throw new ModuleException(sprintf('Module (%s) not activated', $packageName), 501);
     }
     $model = $this->activatedModules->get($packageName);
     if ($model->getInstalledVersion() > $model->getActivatedVersion()) {
         throw new ModuleException(sprintf('Module Version Mismatch (%s). Module needs to be updated by the Administrator', $packageName), 500);
     }
     // load
     $className = $model->getClassName();
     /* @var $module AbstractModule */
     $module = new $className($model, $this->service);
     $this->loadedModules->set($packageName, $module);
     // load locale
     $localeService = $this->getServiceContainer()->getLocaleService();
     $file = sprintf('/%s/locales/{locale}/translations.json', $packageName);
     $localeService->loadLocaleFile($file, $module->getCanonicalName());
     return $module;
 }
Exemplo n.º 12
0
 /**
  * Returns additional includes for a given model
  *
  * @param string $modelName
  * @return ArrayList
  */
 public function getIncludes($modelName)
 {
     if ($this->models->has($modelName) && $this->models->get($modelName)->has('includes')) {
         return $this->models->get($modelName)->get('includes');
     }
     return new ArrayList();
 }
Exemplo n.º 13
0
 public function testArrayAccess()
 {
     $map = new Map();
     $map['a'] = 'b';
     $this->assertEquals(1, $map->size());
     $this->assertTrue($map->has('a'));
     $this->assertFalse($map->has('c'));
     $this->assertTrue($map->contains('b'));
     $this->assertFalse($map->contains('c'));
     $this->assertEquals($map['a'], $map->get('a'));
     $this->assertTrue(isset($map['a']));
     $this->assertFalse(isset($map['c']));
     $map['a'] = 'x';
     $this->assertEquals('x', $map['a']);
     unset($map['a']);
     $this->assertFalse($map->has('a'));
     $this->assertEquals(0, $map->size());
 }
Exemplo n.º 14
0
 /**
  * Returns a constant.
  *
  * @param string|PhpConstant $nameOrConstant
  * @throws \InvalidArgumentException If the constant cannot be found
  * @return PhpConstant
  */
 public function getConstant($nameOrConstant)
 {
     if ($nameOrConstant instanceof PhpConstant) {
         $nameOrConstant = $nameOrConstant->getName();
     }
     if (!$this->constants->has($nameOrConstant)) {
         throw new \InvalidArgumentException(sprintf('The constant "%s" does not exist.', $nameOrConstant));
     }
     return $this->constants->get($nameOrConstant);
 }
Exemplo n.º 15
0
 /**
  * Returns a method
  *
  * @param string $nameOrMethod the methods name
  * @throws \InvalidArgumentException if the method cannot be found
  * @return PhpMethod
  */
 public function getMethod($nameOrMethod)
 {
     if ($nameOrMethod instanceof PhpMethod) {
         $nameOrMethod = $nameOrMethod->getName();
     }
     if (!$this->methods->has($nameOrMethod)) {
         throw new \InvalidArgumentException(sprintf('The method "%s" does not exist.', $nameOrMethod));
     }
     return $this->methods->get($nameOrMethod);
 }
Exemplo n.º 16
0
 /**
  * Returns a property
  *
  * @param string $nameOrProperty property name
  * @throws \InvalidArgumentException If the property cannot be found
  * @return PhpProperty
  */
 public function getProperty($nameOrProperty)
 {
     if ($nameOrProperty instanceof PhpProperty) {
         $nameOrProperty = $nameOrProperty->getName();
     }
     if (!$this->properties->has($nameOrProperty)) {
         throw new \InvalidArgumentException(sprintf('The property "%s" does not exist.', $nameOrProperty));
     }
     return $this->properties->get($nameOrProperty);
 }
Exemplo n.º 17
0
 private function parseType(Map $data)
 {
     $this->type = $data->get('type');
     $this->format = $data->get('format');
     $this->collectionFormat = $data->get('collectionFormat');
     $this->default = $data->get('default');
     $this->maximum = $data->get('maximum');
     $this->exclusiveMaximum = $data->has('exclusiveMaximum') && $data->get('exclusiveMaximum');
     $this->minimum = $data->get('minimum');
     $this->exclusiveMinimum = $data->has('exclusiveMinimum') && $data->get('exclusiveMinimum');
     $this->maxLength = $data->get('maxLength');
     $this->minLength = $data->get('minLength');
     $this->pattern = $data->get('pattern');
     $this->maxItems = $data->get('maxItems');
     $this->minItems = $data->get('minItems');
     $this->uniqueItems = $data->has('uniqueItems') && $data->get('uniqueItems');
     $this->enum = $data->get('enum');
     $this->multipleOf = $data->get('multipleOf');
 }
Exemplo n.º 18
0
 private function parse($contents)
 {
     $data = new Map($contents);
     $this->setFullName($data->get('name'));
     $this->description = $data->get('description');
     $this->type = $data->get('type');
     $this->license = $data->get('license');
     $this->keywords = new ArrayList($data->get('keywords', []));
     $this->authors = new ArrayList();
     if ($data->has('authors')) {
         foreach ($data->get('authors') as $authorData) {
             $this->authors->add(new AuthorSchema($authorData));
         }
     }
     $this->autoload = new AutoloadSchema($data->get('autoload', []));
     $this->require = new Map($data->get('require', []));
     $this->requireDev = new Map($data->get('require-dev', []));
     $this->extra = CollectionUtils::toMap($data->get('extra', []));
     $this->keeko = new KeekoSchema($this, $this->extra->get('keeko', []));
     $this->data = $data;
 }
Exemplo n.º 19
0
 private function registerListeners()
 {
     $reg = $this->service->getExtensionRegistry();
     $listeners = $reg->getExtensions(CoreModule::EXT_LISTENER);
     $map = new Map();
     $getClass = function ($className) use($map) {
         if (class_exists($className)) {
             if ($map->has($className)) {
                 $class = $map->get($className);
             } else {
                 $class = new $className();
                 $map->set($className, $class);
             }
             if ($class instanceof KeekoEventListenerInterface) {
                 $class->setServiceContainer($this->service);
             }
             return $class;
         }
         return null;
     };
     foreach ($listeners as $listener) {
         // subscriber first
         if (isset($listener['subscriber'])) {
             $className = $listener['subscriber'];
             $subscriber = $getClass($className);
             if ($subscriber !== null && $subscriber instanceof KeekoEventSubscriberInterface) {
                 $this->dispatcher->addSubscriber($subscriber);
             }
         }
         // class
         if (isset($listener['class']) && isset($listener['method']) && isset($listener['event'])) {
             $className = $listener['class'];
             $class = $getClass($className);
             if ($class !== null && $class instanceof KeekoEventListenerInterface && method_exists($class, $listener['method'])) {
                 $this->dispatcher->addListener($listener['event'], [$class, $listener['method']]);
             }
         }
     }
 }
Exemplo n.º 20
0
 /**
  * Checks whether a responder with the given type is present
  * 
  * @param string $type
  * @return boolean
  */
 public function hasResponder($type)
 {
     return $this->responder->has($type);
 }
Exemplo n.º 21
0
 public function testTextAsKey()
 {
     $map = new Map();
     $key = new Text('k');
     $map->set($key, 'val');
     $this->assertTrue($map->has($key));
     $this->assertEquals('val', $map->get($key));
     $map->remove($key);
     $this->assertEquals(0, $map->size());
 }
Exemplo n.º 22
0
 /**
  * Returns definitions has a schema with the given name
  *
  * @param string $name
  * @return bool
  */
 public function has($name)
 {
     return $this->definitions->has($name);
 }
Exemplo n.º 23
0
 /**
  * Checks whether an extension point with the given key exists
  *
  * @param string $key
  * @return boolean
  */
 public function hasExtensionPoint($key)
 {
     return $this->extensionPoints->has($key);
 }
Exemplo n.º 24
0
 /**
  * A list of tags sorted by tag-name
  * 
  * @return ArrayList
  */
 public function getSortedTags()
 {
     if ($this->comparator === null) {
         $this->comparator = new TagNameComparator();
     }
     // 1) group by tag name
     $group = new Map();
     foreach ($this->tags as $tag) {
         if (!$group->has($tag->getTagName())) {
             $group->set($tag->getTagName(), new ArrayList());
         }
         $group->get($tag->getTagName())->add($tag);
     }
     // 2) Sort the group by tag name
     $group->sortKeys(new TagNameComparator());
     // 3) flatten the group
     $sorted = new ArrayList();
     foreach ($group->values() as $tags) {
         $sorted->addAll($tags);
     }
     return $sorted;
 }
Exemplo n.º 25
0
 private function parseItems(Map $data)
 {
     if ($data->has('items')) {
         $this->items = new Items($data->get('items'));
     }
 }
Exemplo n.º 26
0
 private function parseRequired(Map $data)
 {
     $this->required = $data->has('required') && $data->get('required');
 }
Exemplo n.º 27
0
 /**
  * Returns whether a header with the given name exists
  *
  * @param string $header
  * @return bool
  */
 public function has($header)
 {
     return $this->headers->has($header);
 }
Exemplo n.º 28
0
 private function parseRef(Map $data)
 {
     $this->ref = $data->get('$ref');
     $this->hasRef = $data->has('$ref');
 }