Esempio n. 1
1
 private function find_routes($org, $dest, &$flights)
 {
     $result = array();
     $queue = new SplPriorityQueue();
     foreach ($flights as $flight) {
         if ($flight['org_id'] == $org) {
             $route = new Route($this->route_opts);
             $num_seats = Flight::get_open_seats_on_flight($flight['flight_id'], $this->user);
             $route->add_flight($flight, $num_seats);
             $queue->insert($route, $route->get_joy());
         }
     }
     //BFS to find all routes that take < 10 hours
     $count = 0;
     while ($queue->count() > 0 && $count < $this->opts['max_results']) {
         $cur_route = $queue->extract();
         if ($cur_route->get_dest() == $dest) {
             $result[] = $cur_route;
             $count++;
             continue;
         }
         foreach ($flights as $flight) {
             if (!array_key_exists($flight['dest_id'], $cur_route->visited) && $flight['org_id'] == $cur_route->get_dest() && $flight['e_depart_time'] > 30 * 60 + $cur_route->get_arrival_time()) {
                 $new_route = $cur_route->copy();
                 $num_seats = Flight::get_open_seats_on_flight($flight['flight_id'], $this->user);
                 $new_route->add_flight($flight, $num_seats);
                 if ($new_route->get_trip_time() < 24 * 60 * 60 && $new_route->seats >= $this->opts['passengers']) {
                     $queue->insert($new_route, $new_route->get_joy());
                 }
             }
         }
     }
     return $result;
 }
 private function find_routes($org, $dest, &$flights)
 {
     $result = array();
     $queue = new SplPriorityQueue();
     foreach ($flights as $flight) {
         if ($flight['org_id'] == $org) {
             $route = new Route($this->route_opts);
             $route->add_flight($flight);
             array_push($this->id, $flight['flight_id']);
             $queue->insert($route, $route->get_joy());
         }
     }
     //BFS to find all routes that take < 10 hours
     $count = 0;
     while ($queue->count() > 0 && $count < $this->opts['max_results']) {
         $cur_route = $queue->extract();
         if ($cur_route->get_dest() == $dest) {
             $result[] = $cur_route;
             $count++;
             continue;
         }
         foreach ($flights as $flight) {
             if ($flight['org_id'] == $cur_route->get_dest() && $flight['e_depart_time'] > 30 * 60 + $cur_route->get_arrival_time()) {
                 $new_route = $cur_route->copy();
                 $new_route->add_flight($flight);
                 array_push($this->id, $flight['flight_id']);
                 if ($new_route->get_trip_time() < 24 * 60 * 60) {
                     $queue->insert($new_route, $new_route->get_joy());
                 }
             }
         }
     }
     return $result;
 }
Esempio n. 3
0
 protected function loadConfiguration()
 {
     $sources = new \SplPriorityQueue();
     foreach ($this->getKomponents() as $komponent) {
         foreach ($komponent->getConfigurationSources($this->getContextName()) as $source) {
             $sources->insert($source, $source->getPriority());
         }
     }
     $cfg = new TestConfigLoader();
     $this->testLoader->loadConfigurationSources($cfg);
     foreach ($this->testLoader->findRules() as $rule) {
         $rule->loadConfigurationSources($cfg);
     }
     foreach ($cfg as $source) {
         $sources->insert($source, $source->getPriority());
     }
     $loader = new ConfigurationLoader();
     $loader->registerLoader(new PhpConfigurationLoader());
     $loader->registerLoader(new YamlConfigurationLoader());
     $config = new Configuration();
     $params = $this->getContainerParams();
     foreach ($sources as $source) {
         $config = $config->mergeWith($source->loadConfiguration($loader, $params));
     }
     foreach ($this->testLoader->findRules() as $rule) {
         $config = $config->mergeWith($rule->loadConfiguration());
     }
     return $config->mergeWith($this->testLoader->loadConfiguration());
 }
Esempio n. 4
0
 public function execute()
 {
     // Get the document object.
     $document = $this->getApplication()->getDocument();
     $viewFormat = $this->getInput()->getWord('format', 'html');
     $viewName = $this->getInput()->getWord('view', 'dashboard');
     $layoutName = $this->getInput()->getWord('layout', 'default');
     $this->getInput()->set('view', $viewName);
     // Register the layout paths for the view
     $paths = new \SplPriorityQueue();
     $themeOverride = JPATH_THEMES . '/' . $this->getApplication()->get('theme') . '/html/' . strtolower($viewName);
     if (is_dir($themeOverride)) {
         $paths->insert($themeOverride, 'normal');
     }
     $paths->insert(JPATH_COBALT . '/View/' . ucfirst($viewName) . '/tmpl', 'normal');
     $viewClass = 'Cobalt\\View\\' . ucfirst($viewName) . '\\' . ucfirst($viewFormat);
     $modelClass = ucfirst($viewName);
     if (class_exists('Cobalt\\Model\\' . $modelClass) === false) {
         $modelClass = 'DefaultModel';
     }
     $model = $this->getModel($modelClass);
     /** @var $view \Joomla\View\AbstractHtmlView **/
     $view = new $viewClass($model, $paths);
     $view->setLayout($layoutName);
     $view->document = $document;
     // Render our view.
     echo $view->render();
     return true;
 }
Esempio n. 5
0
 /**
  * Add a step to the current workflow
  *
  * @param Step         $step
  * @param integer|null $priority
  *
  * @return $this
  */
 public function addStep(Step $step, $priority = null)
 {
     $priority = null === $priority && $step instanceof PriorityStep ? $step->getPriority() : $priority;
     $priority = null === $priority ? 0 : $priority;
     $this->steps->insert($step, $priority);
     return $this;
 }
Esempio n. 6
0
function encode($symb2freq)
{
    $heap = new SplPriorityQueue();
    // Instancia fila de prioridades utilizando max heap.
    $heap->setExtractFlags(SplPriorityQueue::EXTR_BOTH);
    // define o modo de extração no caso extrai array com a prioridade
    foreach ($symb2freq as $sym => $wt) {
        $heap->insert(array($sym => ''), -$wt);
    }
    while ($heap->count() > 1) {
        $lo = $heap->extract();
        // extraio o minimo
        $hi = $heap->extract();
        // extraio o minimo
        foreach ($lo['data'] as &$x) {
            $x = '0' . $x;
        }
        foreach ($hi['data'] as &$x) {
            $x = '1' . $x;
        }
        $heap->insert($lo['data'] + $hi['data'], $lo['priority'] + $hi['priority']);
    }
    $result = $heap->extract();
    return $result['data'];
}
Esempio n. 7
0
 public static function getView($viewName, $layoutName = 'default', $viewFormat = 'html', $vars = null)
 {
     // Get the application
     $app = \Cobalt\Container::fetch('app');
     $document = $app->getDocument();
     $app->input->set('view', $viewName);
     // Register the layout paths for the view
     $paths = new \SplPriorityQueue();
     $themeOverride = JPATH_THEMES . '/' . $app->get('theme') . '/html/' . strtolower($viewName);
     if (is_dir($themeOverride)) {
         $paths->insert($themeOverride, 'normal');
     }
     $paths->insert(JPATH_COBALT . '/View/' . ucfirst($viewName) . '/tmpl', 'normal');
     $viewClass = 'Cobalt\\View\\' . ucfirst($viewName) . '\\' . ucfirst($viewFormat);
     $modelClass = ucfirst($viewName);
     if (class_exists('Cobalt\\Model\\' . $modelClass) === false) {
         $modelClass = 'DefaultModel';
     }
     $model = self::getModel($modelClass);
     /** @var $view \Joomla\View\AbstractHtmlView **/
     $view = new $viewClass($model, $paths);
     $view->setLayout($layoutName);
     $view->document = $document;
     if (isset($vars)) {
         $view->bypass = true;
         foreach ($vars as $varName => $var) {
             $view->{$varName} = $var;
         }
     }
     return $view;
 }
Esempio n. 8
0
 /**
  * 刷新监听者队列
  */
 protected function refreshQueue()
 {
     $this->storage->rewind();
     $this->queue = new \SplPriorityQueue();
     foreach ($this->storage as $listener) {
         $priority = $this->storage->getInfo();
         $this->queue->insert($listener, $priority);
     }
 }
Esempio n. 9
0
function getQueueWithLittleData()
{
    $q = new SplPriorityQueue();
    $q->insert('dux', 4);
    $q->insert('legati', 3);
    $q->insert('centurion', 2);
    $q->insert('munifex', 1);
    return $q;
}
Esempio n. 10
0
 /**
  * Method to load the paths queue.
  *
  * @return  \SplPriorityQueue  The paths queue.
  *
  * @since   1.0.0
  */
 protected function loadPaths()
 {
     $app = \JFactory::getApplication();
     $theme = $app->get('theme');
     $option = $app->input->getString('option');
     $tmplPaths = new \SplPriorityQueue();
     $tmplPaths->insert(JPATH_COMPONENT . '/views/' . $this->name . '/tmpl', 0);
     $tmplPaths->insert(JPATH_THEMES . '/' . $theme . '/html/' . $option . '/' . $this->name, 1);
     return $tmplPaths;
 }
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  *
  * @return void
  */
 protected function setUp()
 {
     $paths = new \SplPriorityQueue();
     $paths->insert('libraries/windwalker/resource/asset/{type}', 800);
     $paths->insert('libraries/windwalker/test/Asset/Stub/{type}', 500);
     $paths->insert('media/jui/{type}', 300);
     $paths->insert('media/{name}/{type}', 100);
     $this->instance = new AssetManager('test', $paths);
     $this->instance->setDoc($this->doc = new MockHtmlDocument());
     $this->doc->reset();
 }
Esempio n. 12
0
 /**
  * Attach a filter to the chain
  *
  * @param  callable|FilterInterface $callback
  * @param  int $priority
  * @throws \InvalidArgumentException
  * @return FilterChain
  */
 public function attach($callback, $priority = self::DEFAULT_PRIORITY)
 {
     if (!is_callable($callback)) {
         if (!$callback instanceof FilterInterface) {
             throw new \InvalidArgumentException(sprintf('Expected a valid PHP callback; received "%s"', is_object($callback) ? get_class($callback) : gettype($callback)));
         }
         $callback = [$callback, 'filter'];
     }
     $this->filters->insert($callback, $priority);
     return $this;
 }
Esempio n. 13
0
 public function spl_priority_queue_is_useful_for_custom_priorities()
 {
     $priority_queue = new SplPriorityQueue();
     $priority_queue->insert('o', 1);
     $priority_queue->insert('i', 3);
     $priority_queue->insert('S', 4);
     $priority_queue->insert('n', 0);
     $priority_queue->insert('m', 2);
     $result = [];
     foreach ($priority_queue as $value) {
         $result[] = $value;
     }
     assert_that(implode($result))->is_identical_to(__);
 }
Esempio n. 14
0
 public function process(ContainerBuilder $container)
 {
     if (false === $container->hasDefinition('profiler')) {
         return;
     }
     $definition = $container->getDefinition('profiler');
     $collectors = new \SplPriorityQueue();
     $order = PHP_INT_MAX;
     foreach ($container->findTaggedServiceIds('data_collector') as $id => $attributes) {
         $priority = isset($attributes[0]['priority']) ? $attributes[0]['priority'] : 0;
         $template = null;
         if (isset($attributes[0]['template'])) {
             if (!isset($attributes[0]['id'])) {
                 throw new \InvalidArgumentException(sprintf('Data collector service "%s" must have an id attribute in order to specify a template', $id));
             }
             $template = array($attributes[0]['id'], $attributes[0]['template']);
         }
         $collectors->insert(array($id, $template), array($priority, --$order));
     }
     $templates = array();
     foreach ($collectors as $collector) {
         $definition->addMethodCall('add', array(new Reference($collector[0])));
         $templates[$collector[0]] = $collector[1];
     }
     $container->setParameter('data_collector.templates', $templates);
 }
Esempio n. 15
0
 /**
  * Executes any pending timers. Returns the number of timers executed.
  *
  * @return int
  *
  * @internal
  */
 public function tick() : int
 {
     $count = 0;
     $time = microtime(true);
     while (!$this->queue->isEmpty()) {
         list($timer, $timeout) = $this->queue->top();
         if (!$this->timers->contains($timer) || $timeout !== $this->timers[$timer]) {
             $this->queue->extract();
             // Timer was removed from queue.
             continue;
         }
         if ($this->timers[$timer] > $time) {
             // Timer at top of queue has not expired.
             return $count;
         }
         // Remove and execute timer. Replace timer if persistent.
         $this->queue->extract();
         if ($timer->isPeriodic()) {
             $timeout = $time + $timer->getInterval();
             $this->queue->insert([$timer, $timeout], -$timeout);
             $this->timers[$timer] = $timeout;
         } else {
             $this->timers->detach($timer);
         }
         // Execute the timer.
         $timer->call();
         ++$count;
     }
     return $count;
 }
Esempio n. 16
0
 /**
  * 检查是否有可执行的定时任务,有的话执行
  * @return void
  */
 protected function tick()
 {
     while (!$this->_scheduler->isEmpty()) {
         $scheduler_data = $this->_scheduler->top();
         $timer_id = $scheduler_data['data'];
         $next_run_time = -$scheduler_data['priority'];
         $time_now = microtime(true);
         if ($time_now >= $next_run_time) {
             $this->_scheduler->extract();
             // 如果任务不存在,则是对应的定时器已经删除
             if (!isset($this->_task[$timer_id])) {
                 continue;
             }
             // 任务数据[func, args, flag, timer_interval]
             $task_data = $this->_task[$timer_id];
             // 如果是持续的定时任务,再把任务加到定时队列
             if ($task_data[2] === self::EV_TIMER) {
                 $next_run_time = $time_now + $task_data[3];
                 $this->_scheduler->insert($timer_id, -$next_run_time);
             }
             // 尝试执行任务
             try {
                 call_user_func_array($task_data[0], $task_data[1]);
             } catch (\Exception $e) {
                 echo $e;
             }
             continue;
         } else {
             // 设定超时时间
             $this->_selectTimeout = ($next_run_time - $time_now) * 1000000;
             return;
         }
     }
     $this->_selectTimeout = 100000000;
 }
Esempio n. 17
0
 public function insert($datum, $priority, $rulePriority = 0)
 {
     if (is_int($priority)) {
         $priority = array($priority, $rulePriority, $this->queueOrder++);
     }
     parent::insert($datum, $priority);
 }
Esempio n. 18
0
 /**
  * Tick for timer.
  * @return void
  */
 protected function tick()
 {
     while (!$this->_scheduler->isEmpty()) {
         $scheduler_data = $this->_scheduler->top();
         $timer_id = $scheduler_data['data'];
         $next_run_time = -$scheduler_data['priority'];
         $time_now = microtime(true);
         if ($time_now >= $next_run_time) {
             $this->_scheduler->extract();
             if (!isset($this->_task[$timer_id])) {
                 continue;
             }
             // [func, args, flag, timer_interval]
             $task_data = $this->_task[$timer_id];
             if ($task_data[2] === self::EV_TIMER) {
                 $next_run_time = $time_now + $task_data[3];
                 $this->_scheduler->insert($timer_id, -$next_run_time);
             }
             call_user_func_array($task_data[0], $task_data[1]);
             if (isset($this->_task[$timer_id]) && $task_data[2] === self::EV_TIMER_ONCE) {
                 $this->del($timer_id, self::EV_TIMER_ONCE);
             }
             continue;
         } else {
             $this->_selectTimeout = ($next_run_time - $time_now) * 1000000;
             return;
         }
     }
     $this->_selectTimeout = 100000000;
 }
Esempio n. 19
0
 /**
  * @param string $event
  * @param array  $params
  * @param string $context
  */
 public function trigger($event, $params = [], $context = '')
 {
     if (empty($this->events[$event])) {
         return;
     }
     $queue = new \SplPriorityQueue();
     foreach ($this->events[$event] as $index => $action) {
         $queue->insert($index, $action['prio']);
     }
     $queue->top();
     while ($queue->valid()) {
         $index = $queue->current();
         if (!empty($context)) {
             $contexts = explode(',', $this->events[$event][$index]['contexts']);
             $current_context = false;
             foreach ($contexts as $route) {
                 if (fnmatch(trim($route), $context)) {
                     $current_context = true;
                     break;
                 }
             }
         } else {
             $current_context = true;
         }
         if ($current_context && is_callable($this->events[$event][$index]['fn'])) {
             if (call_user_func_array($this->events[$event][$index]['fn'], $params) === false) {
                 break;
             }
         }
         $queue->next();
     }
 }
Esempio n. 20
0
 /**
  * Detach the listener from the events manager
  *
  * @param string eventType
  * @param object handler
  */
 public function detach($eventType, $handler)
 {
     if (!is_object($handler)) {
         throw new \Exception("Event handler must be an Object");
     }
     if (isset($this->_events[$eventType])) {
         if (is_object($this->_events[$eventType])) {
             // SplPriorityQueue hasn't method for element deletion, so we need to rebuild queue
             $newPriorityQueue = new PriorityQueue();
             $newPriorityQueue->setExtractFlags(\SplPriorityQueue::EXTR_DATA);
             $priorityQueue->setExtractFlags(PriorityQueue::EXTR_BOTH);
             $priorityQueue->top();
             while ($priorityQueue->valid()) {
                 $data = $priorityQueue->current();
                 $priorityQueue->next();
                 if ($data['data'] !== $handler) {
                     $newPriorityQueue->insert($data['data'], $data['priority']);
                 }
             }
             $this->_events[$eventType] = $newPriorityQueue;
         } else {
             $key = array_search($handler, $priorityQueue, true);
             if ($key !== false) {
                 unset($priorityQueue[$key]);
             }
             $this->_events[$eventType] = $priorityQueue;
         }
     }
 }
 /**
  * {@inheritDoc}
  */
 public function __construct($options = null)
 {
     if (is_array($options) && !array_intersect(array_keys($options), array('constraints', 'stopOnError'))) {
         $options = array('constraints' => $options);
     }
     parent::__construct($options);
     // convert array of constraints into SplPriorityQueue
     if (is_array($this->constraints)) {
         $queue = new \SplPriorityQueue();
         $constraints = $this->constraints;
         $constraints = array_reverse($constraints);
         foreach ($constraints as $index => $constraint) {
             $queue->insert($constraint, $index);
         }
         $this->constraints = $queue;
     }
     if (!$this->constraints instanceof \SplPriorityQueue) {
         throw new ConstraintDefinitionException('The option "constraints" is expected to be a SplPriorityQueue in constraint ' . __CLASS__ . '.');
     }
     $constraintsCopy = $this->getConstraints();
     // set extraction mode to both priority and data
     $constraintsCopy->setExtractFlags(\SplPriorityQueue::EXTR_BOTH);
     // loop through the priority chain for options validation
     while ($constraintsCopy->valid()) {
         $constraint = $constraintsCopy->current();
         // fail if the constraint is not actually a constraint
         if (!$constraint['data'] instanceof Constraint) {
             throw new ConstraintDefinitionException('The option "constraints" (priority: ' . $constraint['priority'] . ') is not a Constraint, in ' . __CLASS__ . '.');
         }
         // move to next constraint
         $constraintsCopy->next();
     }
 }
 /**
  * {@inheritdoc}
  */
 public function process(ContainerBuilder $container)
 {
     if (!$container->hasDefinition('gremo_buzz')) {
         return;
     }
     // Build listeners queue from tagged services
     $listeners = new \SplPriorityQueue();
     foreach ($container->findTaggedServiceIds('gremo_buzz.listener') as $id => $attrs) {
         $class = $container->getDefinition($id)->getClass();
         $class = $container->getParameterBag()->resolveValue($class);
         $reflector = new \ReflectionClass($class);
         $interface = 'Buzz\\Listener\\ListenerInterface';
         // Check if the service implements the above interface
         if (!$reflector->isSubclassOf($interface)) {
             throw new InvalidArgumentException(sprintf("Service '%s' must implement '%s'.", $id, $interface));
         }
         // Add a reference to the listeners queue providing a default priority
         $listeners->insert(new Reference($id), isset($attrs[0]['priority']) ? $attrs[0]['priority'] : 0);
     }
     if (!empty($listeners)) {
         $browser = $container->getDefinition('gremo_buzz');
         // Add listeners starting from those with higher priority
         foreach ($listeners as $listener) {
             $browser->addMethodCall('addListener', array($listener));
         }
     }
 }
Esempio n. 23
0
 /**
  * Insert a value with a given priority
  *
  * Utilizes {@var $serial} to ensure that values of equal priority are
  * emitted in the same order in which they are inserted.
  *
  * @param  mixed $datum
  * @param  mixed $priority
  * @return void
  */
 public function insert($datum, $priority)
 {
     if (!is_array($priority)) {
         $priority = [$priority, $this->serial--];
     }
     parent::insert($datum, $priority);
 }
 public function insert($value, $priority)
 {
     if (is_int($priority)) {
         $priority = array($priority, --$this->counter);
     }
     parent::insert($value, $priority);
 }
Esempio n. 25
0
 /**
  * Register default paths.
  *
  * @param boolean $includeTemplate True to include template path. Should be false before system routing.
  *
  * @return void
  */
 protected function registerPaths($includeTemplate = true)
 {
     $app = $this->getContainer()->get('app');
     $prefix = $app->isAdmin() ? 'administrator/' : '';
     if ($includeTemplate) {
         // (1) Find: templates/[tmpl]/[type]/[name]/[file_name].[type]
         $this->paths->insert($prefix . 'templates/' . $app->getTemplate() . '/{type}/{name}', 800);
         // (2) Find: templates/[tmpl]/[type]/[file_name].[type]
         $this->paths->insert($prefix . 'templates/' . $app->getTemplate() . '/{type}', 700);
     }
     // (3) Find: components/[name]/asset/[type]/[file_name].[type]
     $this->paths->insert($prefix . 'components/{name}/asset/{type}', 600);
     // (4) Find: components/[name]/asset/[file_name].[type]
     $this->paths->insert($prefix . 'components/{name}/asset', 500);
     // (5) Find: media/[name]/[type]/[file_name].[type]
     $this->paths->insert('media/{name}/{type}', 400);
     // (6) Find: media/[name]/[file_name].[type]
     $this->paths->insert('media/{name}', 300);
     // (7) Find: media/windwalker/[type]/[file_name].[type]
     $this->paths->insert('media/windwalker/{type}', 200);
     // (8) Find: media/windwalker/[file_name].[type]
     $this->paths->insert('media/windwalker', 100);
     // (9) Find: libraries/windwalker/resource/asset/[type]/[file_name].[type] (For legacy)
     $this->paths->insert('libraries/windwalker/resource/asset/{type}', 50);
     // (10) Find: libraries/windwalker/resource/assets/[file_name].[type] (For legacy)
     $this->paths->insert('libraries/windwalker/resource/asset', 20);
     // (11) Find: libraries/windwalker/assets/[file_name].[type] (For legacy)
     $this->paths->insert('libraries/windwalker/assets', 10);
 }
Esempio n. 26
0
 /**
  * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
  *
  * @throws \InvalidArgumentException
  */
 public function process(ContainerBuilder $container)
 {
     // configure the profiler service
     if (FALSE === $container->hasDefinition('profiler')) {
         return;
     }
     $definition = $container->getDefinition('profiler');
     $collectors = new \SplPriorityQueue();
     $order = PHP_INT_MAX;
     foreach ($container->findTaggedServiceIds('data_collector') as $id => $attributes) {
         $priority = isset($attributes[0]['priority']) ? $attributes[0]['priority'] : 0;
         $template = NULL;
         if (isset($attributes[0]['template'])) {
             if (!isset($attributes[0]['id'])) {
                 throw new \InvalidArgumentException(sprintf('Data collector service "%s" must have an id attribute in order to specify a template', $id));
             }
             if (!isset($attributes[0]['title'])) {
                 throw new \InvalidArgumentException(sprintf('Data collector service "%s" must have a title attribute', $id));
             }
             $template = [$attributes[0]['id'], $attributes[0]['template'], $attributes[0]['title']];
         }
         $collectors->insert([$id, $template], [-$priority, --$order]);
     }
     $templates = [];
     foreach ($collectors as $collector) {
         $definition->addMethodCall('add', [new Reference($collector[0])]);
         $templates[$collector[0]] = $collector[1];
     }
     $container->setParameter('data_collector.templates', $templates);
     // set parameter to store the public folder path
     $path = 'file:' . DRUPAL_ROOT . '/' . PublicStream::basePath() . '/profiler';
     $container->setParameter('data_collector.storage', $path);
 }
Esempio n. 27
0
 public function execute()
 {
     // Get the application
     $app = JFactory::getApplication();
     $params = JComponentHelper::getParams('com_ddcbalanceit');
     if ($params->get('required_account') == 1) {
         $user = JFactory::getUser();
         if ($user->get('guest')) {
             $app->redirect('index.php', JText::_('COM_DDCBALANCEIT_ACCOUNT_REQUIRED_MSG'));
         }
     }
     // Get the document object.
     $document = JFactory::getDocument();
     $viewName = $app->input->getWord('view', 'dashboard');
     $viewFormat = $document->getType();
     $layoutName = $app->input->getWord('layout', 'default');
     $app->input->set('view', $viewName);
     // Register the layout paths for the view
     $paths = new SplPriorityQueue();
     $paths->insert(JPATH_COMPONENT . '/views/' . $viewName . '/tmpl', 'normal');
     $viewClass = 'DdcbalanceitViews' . ucfirst($viewName) . ucfirst($viewFormat);
     $modelClass = 'DdcbalanceitModels' . ucfirst($viewName);
     if (false === class_exists($modelClass)) {
         $modelClass = 'DdcbalanceitModelsDefault';
     }
     $view = new $viewClass(new $modelClass(), $paths);
     $view->setLayout($layoutName);
     // Render our view.
     echo $view->render();
     return true;
 }
Esempio n. 28
0
 public function insert($value, $priority)
 {
     if (!$value instanceof ProviderInterface) {
         throw new \LogicException("Only objects which implement ProviderInterface can be added to the provider container");
     }
     parent::insert($value, $priority);
 }
Esempio n. 29
0
 public function process(ContainerBuilder $container)
 {
     $definitions = new \SplPriorityQueue();
     $order = PHP_INT_MAX;
     foreach ($container->getDefinitions() as $id => $definition) {
         if (!($decorated = $definition->getDecoratedService())) {
             continue;
         }
         $definitions->insert(array($id, $definition), array($decorated[2], --$order));
     }
     foreach ($definitions as list($id, $definition)) {
         list($inner, $renamedId) = $definition->getDecoratedService();
         $definition->setDecoratedService(null);
         if (!$renamedId) {
             $renamedId = $id . '.inner';
         }
         // we create a new alias/service for the service we are replacing
         // to be able to reference it in the new one
         if ($container->hasAlias($inner)) {
             $alias = $container->getAlias($inner);
             $public = $alias->isPublic();
             $container->setAlias($renamedId, new Alias((string) $alias, false));
         } else {
             $definition = $container->getDefinition($inner);
             $public = $definition->isPublic();
             $definition->setPublic(false);
             $container->setDefinition($renamedId, $definition);
         }
         $container->setAlias($inner, new Alias($id, $public));
     }
 }
Esempio n. 30
0
 public function process(ContainerBuilder $container)
 {
     if ($container->hasDefinition('templating')) {
         return;
     }
     if ($container->hasDefinition('templating.engine.php')) {
         $helpers = array();
         foreach ($container->findTaggedServiceIds('templating.helper') as $id => $attributes) {
             if (isset($attributes[0]['alias'])) {
                 $helpers[$attributes[0]['alias']] = $id;
             }
         }
         $definition = $container->getDefinition('templating.engine.php');
         $arguments = $definition->getArguments();
         $definition->setArguments($arguments);
         if (count($helpers) > 0) {
             $definition->addMethodCall('setHelpers', array($helpers));
         }
     }
     if ($container->hasDefinition('templating.engine.delegating')) {
         $queue = new \SplPriorityQueue();
         foreach ($container->findTaggedServiceIds('templating.engine') as $id => $attributes) {
             $queue->insert($id, isset($attributes[0]['priority']) ? $attributes[0]['priority'] : 0);
         }
         $engines = array();
         foreach ($queue as $engine) {
             $engines[] = $engine;
         }
         $container->getDefinition('templating.engine.delegating')->addMethodCall('setEngineIds', array($engines));
     }
 }