/** * @param string $name * @return string * @throws \OutOfBoundsException */ public function getClassByEventName(string $name) { if (!$this->innerMap->containsKey($name)) { throw new \OutOfBoundsException("Event class not mapped: '{$name}'."); } return $this->innerMap->get($name)->get(); }
/** * Translate view path * * @param string $identifier * * @return string * * @throws InvalidArgumentException */ public function translate($identifier) { $parts = explode(':', $identifier, 2); if (count($parts) == 2) { $basePath = $this->paths->get($parts[0])->getOrThrow(new InvalidArgumentException('Invalid application name for view identifier: ' . $identifier)); if (!file_exists($basePath . DIRECTORY_SEPARATOR . $parts[1])) { throw new InvalidArgumentException('Invalid view name'); } return $basePath . DIRECTORY_SEPARATOR . $parts[1]; } else { throw new InvalidArgumentException('Invalid view name provided'); } }
/** * Trigger event. * * @param AbstractEvent $event */ public function trigger(AbstractEvent $event) { $queue = clone $this->queues->get($event->getEventId())->getOrElse(new \SplPriorityQueue()); /* @var $queue \SplPriorityQueue */ while ($queue->valid()) { $callback = $queue->extract(); call_user_func_array($callback, ['event' => $event]); if (is_array($callback)) { $subscriber = get_class($callback[0]) . '::' . $callback[1]; } elseif (is_string($callback)) { $subscriber = $callback; } else { $subscriber = get_class($callback); } $this->logger->debug("Event '" . $event->getEventId() . "' triggered '" . $subscriber . "'"); if (!$event->shouldPropagate()) { $this->logger->debug("'{$subscriber}' stopped propagation of '" . $event->getEventId() . "'"); break; } } }
/** * Get the value of a map's element * * @param string $key * * @return mixed */ public function get($key) { return $this->map->get($key)->get(); }
/** * @return array */ public function getGroups() { return $this->attributes->get('groups'); }
/** * Get response cookies * * @return Map */ public function getCookies() { return $this->headers->get('Set-Cookie')->getOrElse([]); }
public function get($key) { $this->initialize($key); return parent::get($key); }
public function testRemove() { $this->assertTrue($this->map->get('foo')->isDefined()); $this->assertEquals('bar', $this->map->remove('foo')); $this->assertFalse($this->map->get('foo')->isDefined()); }
/** * Get Response Option * * @param string $name * * @return Some|None */ public function getResponseOption($name) { return $this->responseOptions->get($name); }