Example #1
0
 public static final function entityManager()
 {
     if (self::$entityManager === null) {
         self::$entityManager = self::$entityManagerFactory->__invoke();
     }
     return self::$entityManager;
 }
Example #2
0
 /**
  * {@inheritdoc}
  */
 public function __invoke($input, $index)
 {
     /** @noinspection PhpMethodParametersCountMismatchInspection */
     /** @noinspection PhpMethodParametersCountMismatchInspection */
     /** @noinspection PhpVoidFunctionResultUsedInspection */
     return $this->function->__invoke($input, $index);
 }
Example #3
0
 /**
  * Evaluates the underyling closure and returns its result.
  *
  * The given Options instance is passed to the closure as first argument.
  * The previous default value set in the constructor is passed as second
  * argument.
  *
  * @param Options $options The container with all concrete options.
  *
  * @return mixed The result of the closure.
  */
 public function evaluate(Options $options)
 {
     if ($this->previousValue instanceof self) {
         $this->previousValue = $this->previousValue->evaluate($options);
     }
     return $this->closure->__invoke($options, $this->previousValue);
 }
 /**
  * Activate the dependency and set it in the object.
  *
  * @return object The real dependency object
  * @api
  */
 public function _activateDependency()
 {
     $realDependency = $this->builder->__invoke();
     foreach ($this->propertyVariables as &$propertyVariable) {
         $propertyVariable = $realDependency;
     }
     return $realDependency;
 }
Example #5
0
 /**
  * @inheritdoc
  */
 public function process()
 {
     if ($this->processType == self::PROCESS_TYPE_CLOSURE) {
         return $this->process->__invoke($this->getParent());
     } elseif ($this->processType == self::PROCESS_TYPE_CALLABLE) {
         return call_user_func($this->process, $this->getParent());
     }
     return true;
 }
Example #6
0
 /**
  * {@inheritDoc}
  */
 public function isAllowed($resource, $privilege = null, $role = null)
 {
     $this->loaded && $this->loaded->__invoke();
     try {
         return $this->acl->isAllowed($role ?: $this->identity, $resource, $privilege);
     } catch (InvalidArgumentException $e) {
         return false;
     }
 }
Example #7
0
 /**
  * @param string $msg
  * @param bool $writeln
  */
 public function log($msg, $writeln = true)
 {
     $prefixed = '';
     foreach ($this->logPrefixes as $prefix) {
         $prefixed .= $prefixed ? ' ' . $prefix : $prefix;
     }
     $msg = $prefixed ? $prefixed . ' ' . $msg : $msg;
     $this->logger->__invoke($msg, $writeln);
 }
Example #8
0
 public function valid()
 {
     if (count($this->batch) < 1) {
         $this->batch = $this->provider->__invoke($this->key, $this->batch_size);
         if ($this->batch && $this->batch instanceof \Traversable) {
             $this->batch = iterator_to_array($this->batch);
         }
     }
     return count($this->batch) > 0;
 }
 /**
  * Invokes the advice method
  *
  * @param \TYPO3\Flow\Aop\JoinPointInterface $joinPoint The current join point which is passed to the advice method
  * @return mixed Result of the advice method
  */
 public function invoke(\TYPO3\Flow\Aop\JoinPointInterface $joinPoint)
 {
     if ($this->runtimeEvaluator !== null && $this->runtimeEvaluator->__invoke($joinPoint, $this->objectManager) === false) {
         return;
     }
     $adviceObject = $this->objectManager->get($this->aspectObjectName);
     $methodName = $this->adviceMethodName;
     $adviceObject->{$methodName}($joinPoint);
     $this->emitAdviceInvoked($adviceObject, $methodName, $joinPoint);
 }
Example #10
0
 /** @inheritdoc */
 public function isValid($value)
 {
     $this->lastValidated = $value;
     try {
         if (isset($this->customValidateMethod)) {
             $this->customValidateMethod->__invoke($this->objectName, $value);
         }
         return $this->validateValue($value);
     } catch (\Exception $e) {
         $this->error = $e->getMessage();
         return false;
     }
 }
 /**
  * Searches for an applicable redirection record in the $redirectionRepository and sends redirect headers if one was found
  *
  * @param HttpRequest $request
  * @return void
  * @api
  */
 public function triggerRedirectIfApplicable(HttpRequest $request)
 {
     try {
         $redirection = $this->redirectionRepository->findOneByRequest($request);
     } catch (\Exception $exception) {
         // skip triggering the redirect if there was an error accessing the database (wrong credentials, ...)
         return;
     }
     if ($redirection === NULL) {
         return;
     }
     $this->sendRedirectHeaders($request, $redirection);
     $this->exit->__invoke();
 }
Example #12
0
 /**
  * @return Html
  */
 public function getCell()
 {
     if ($this->cell === NULL) {
         $this->cell = $this->cellFactory->__invoke();
     }
     return $this->cell;
 }
Example #13
0
 /**
  * @return \Closure|string
  */
 public function getHandler($invoke = \true)
 {
     if ($invoke === \true && $this->handler instanceof \Closure) {
         return $this->handler->__invoke();
     }
     return $this->handler;
 }
Example #14
0
function myCapture(Closure $closure)
{
    ob_start();
    $closure->__invoke();
    $contents = ob_get_contents();
    ob_end_clean();
    return $contents;
}
Example #15
0
 public function getExportName(Option $option)
 {
     if ($option->isUnnamed) {
         return $this->unnamedMapper->__invoke($option->name);
     } else {
         return $this->namedMapper->__invoke($option->name);
     }
 }
Example #16
0
 /**
  * Save a profiling run.
  *
  * @param Domain\Model\ProfilingRun $run
  * @throws \Exception
  * @return void
  */
 public function save(Domain\Model\ProfilingRun $run)
 {
     $configuration = $this->configurationProvider->__invoke();
     if (!isset($configuration['plumber']['profilePath'])) {
         throw new \Exception('Profiling path not set');
     }
     $run->save($configuration);
 }
 /**
  * @return array
  */
 public function getDatabaseFilterValue()
 {
     if ($this->databaseFilterValue === null) {
         return $this->getValue();
     } elseif ($this->databaseFilterValue instanceof \Closure) {
         return $this->databaseFilterValue->__invoke($this);
     }
     return $this->databaseFilterValue;
 }
Example #18
0
 /**
  * If debug mode is set, sends $info to debugger Closure.
  *
  * @param  mixed $info  Info to debug. It will be converted to string.
  */
 public function debugInfo($info)
 {
     if ($this->debug_mode && (is_object($this->debugger) && $this->debugger instanceof Closure)) {
         list(, $caller) = debug_backtrace(false);
         $caller_function = $caller['function'];
         $caller_class = $caller['class'];
         $this->debugger->__invoke($caller_class . '::' . $caller_function . ' > ' . $info);
     }
 }
Example #19
0
 /**
  * Retrieves data by key or executes $callback in case of cache miss. Data returned
  * by $callback is then cached.
  *
  *     \rox\Cache::fetch('my_key', '+1 hour', function(){
  *         // some expensive operation
  *         return $results;
  *     });
  *
  * @param string $key 
  * @param string $expires expiration time in seconds or strtotime() compatible string
  * @param \Closure $callback closure to be executed on cache miss
  * @return mixed
  */
 public static function fetch($key, $expires, \Closure $callback)
 {
     $data = static::read($key);
     if ($data === false) {
         $data = $callback->__invoke();
         static::write($key, $data, $expires);
     }
     return $data;
 }
Example #20
0
 public function current()
 {
     $row = parent::current();
     if ($this->callback) {
         $row = $this->callback->__invoke($row);
     }
     if ($this->skipFields) {
         foreach ($this->skipFields as $field) {
             if (isset($row[$field])) {
                 unset($row[$field]);
             }
         }
     }
     $keys = null;
     if ($this->combineOffset) {
         foreach ($this->combineOffset as $offsetKey => $offsetValue) {
             $keys = array_keys($row);
             $row[$row[$keys[$offsetKey]]] = $row[$keys[$offsetValue]];
             unset($row[$keys[$offsetKey]]);
             unset($row[$keys[$offsetValue]]);
         }
     }
     if ($this->combineFields) {
         foreach ($this->combineFields as $fieldKey => $fieldValue) {
             $row[$row[$fieldKey]] = $row[$fieldValue];
             unset($row[$fieldKey]);
             unset($row[$fieldValue]);
         }
     }
     if ($this->changeKeys) {
         if (!$keys) {
             $keys = array_keys($row);
         }
         foreach ($keys as &$key) {
             if (isset($this->changeKeys[$key])) {
                 $key = $this->changeKeys[$key];
             }
         }
         unset($key);
         $row = array_combine($keys, $row);
     }
     return $row;
 }
 /**
  * Transformator which will rewrite all HTTPS and HTTP urls to
  * @param \HTMLPurifier_URI $uri
  * @param HTMLPurifier_Config $config
  * @param \HTMLPurifier_Context $context
  * @return bool
  */
 public function filter(&$uri, $config, $context)
 {
     /** @var \HTMLPurifier_Context $context */
     /** @var \HTMLPurifier_Config $config */
     // Only HTTPS and HTTP urls should get rewritten
     if ($uri->scheme === 'https' || $uri->scheme === 'http') {
         $uri = $this->filterHttp($uri, $context);
     }
     if ($uri->scheme === 'cid') {
         $attachmentId = $this->mapCidToAttachmentId->__invoke($uri->path);
         if (is_null($attachmentId)) {
             return true;
         }
         $this->messageParameters['attachmentId'] = $attachmentId;
         $imgUrl = $this->urlGenerator->linkToRouteAbsolute('mail.messages.downloadAttachment', $this->messageParameters);
         $parser = new HTMLPurifier_URIParser();
         $uri = $parser->parse($imgUrl);
     }
     return true;
 }
Example #22
0
 /**
  * @param $class
  *
  * @return \ReflectionClass
  *
  * @throws UnexpectedValueException
  */
 public function getReflectionClass($class)
 {
     if ($this->reflectionClassInjector === null) {
         $reflectionClass = new \ReflectionClass($class);
     } else {
         $reflectionClass = $this->reflectionClassInjector->__invoke($class);
         if ($reflectionClass instanceof \ReflectionClass === false) {
             throw new UnexpectedValueException('Reflection class injector must return a \\reflectionClass instance');
         }
     }
     return $reflectionClass;
 }
 /**
  * Returns the data stream which can deliver the content of this storage object
  *
  * @return resource A data stream resource; if the stream is seekable, it is rewound to the start
  */
 public function getStream()
 {
     if ($this->stream instanceof \Closure) {
         $this->stream = $this->stream->__invoke();
     }
     if (is_resource($this->stream)) {
         $meta = stream_get_meta_data($this->stream);
         if ($meta['seekable']) {
             rewind($this->stream);
         }
     }
     return $this->stream;
 }
Example #24
0
 /**
  * Scans `$text` looking for profanity. The callback is invoked on
  * each instance of profanity.
  *
  * The signature of `$callback` is:
  * 
  *    function ($word, $index, $types) { ... }
  * 
  * Where `$word` is the possible profane word, `$index` is the offset of the word
  * in the text, and `$types` is a list of tags for the word.
  * 
  * @param string $text
  * @param Closure $callback
  * @return void
  */
 public function scan($text, \Closure $callback)
 {
     preg_match_all('/\\w+/u', $text, $matches, PREG_OFFSET_CAPTURE);
     foreach ($matches[0] as $match) {
         list($word, $index) = $match;
         $key = mb_strtolower($word);
         if (array_key_exists($key, $this->_matchers['simple'])) {
             if ($callback->__invoke($word, $index, $this->_matchers['simple'][$key]) === false) {
                 return;
             }
         }
     }
     foreach ($this->_matchers['regex'] as $regex => $types) {
         preg_match_all('/' . $regex . '/i', $text, $matches, PREG_OFFSET_CAPTURE);
         foreach ($matches[0] as $match) {
             list($word, $index) = $match;
             if ($callback->__invoke($word, $index, $types) === false) {
                 return;
             }
         }
     }
 }
Example #25
0
 /**
  * Render the field and return it as a string.
  *
  * @return string
  */
 public function render()
 {
     //always validate
     $this->isValid();
     //repopulate submitted fields
     if ($this->_form->isSubmitted()) {
         $this->attribute('value', $this->getSubmittedValue());
     }
     //Some fields have unusual logic (e.g. checkboxes) preRender actions allow this to occur without complicating
     //the render template
     $this->_preRenderAction ? $this->_preRenderAction->__invoke($this) : null;
     $errorRenderer = $this->_errorTemplate ?: $this->_getDefaultErrorTemplate();
     return ($this->_fieldTemplate ? $this->_fieldTemplate->__invoke($this) : '') . $errorRenderer($this);
 }
Example #26
0
    /**
     * @return string
     */
    public function __toString()
    {
        try {
            $this->__initialized__ && $this->__initialized__->__invoke();
            return <<<JQUERY
{$this->headMeta()}
{$this->headLink()}
{$this->headStyle()}
{$this->headScript()}
JQUERY;
        } catch (\Exception $e) {
            return $e->getMessage();
        }
    }
Example #27
0
 /**
  * Find value
  * @return float
  */
 public function findValue()
 {
     for ($i = 0; $i < $this->MaxIterations; ++$i) {
         $value = $this->Function->__invoke($this->Current);
         if (abs($value - $this->Goal) < $this->Epsilon) {
             break;
         } elseif ($this->decreasingFactor * $value > $this->Goal * $this->decreasingFactor) {
             $this->Upper = $this->Current;
         } else {
             $this->Lower = $this->Current;
         }
         $this->Current = ($this->Lower + $this->Upper) / 2;
     }
     return $this->Current;
 }
Example #28
0
 /**
  * Log messages to resource
  *
  * @param mixed          $level    The level of the log message
  * @param string|object  $message  If an object is passed it must implement __toString()
  * @param array          $context  Placeholders to be substituted in the message
  *
  * @return static
  */
 public function log($level, $message, array $context = [])
 {
     $level = isset($this->logLevels[$level]) ? $level : LogLevel::INFO;
     list($logLevel, $fore, $back, $style) = $this->logLevels[$level];
     if ($logLevel > $this->level) {
         return $this;
     }
     if (is_callable($this->formatter)) {
         $message = $this->formatter->__invoke($this->logLevels[$level][4], $message, $context);
     } else {
         $message = $this->formatMessage($level, $message, $context);
     }
     $this->lastLogEntry = $message;
     $this->write($this->colourize($message, $fore, $back, $style) . PHP_EOL);
     return $this;
 }
 /**
  * Handles a HTTP request
  *
  * @return void
  */
 public function handleRequest()
 {
     // Create the request very early so the Resource Management has a chance to grab it:
     $this->request = Request::createFromEnvironment();
     $this->response = new Response();
     $this->boot();
     $this->resolveDependencies();
     if (isset($this->settings['http']['baseUri'])) {
         $this->request->setBaseUri(new Uri($this->settings['http']['baseUri']));
     }
     $componentContext = new ComponentContext($this->request, $this->response);
     $this->baseComponentChain->handle($componentContext);
     $this->response->send();
     $this->bootstrap->shutdown(Bootstrap::RUNLEVEL_RUNTIME);
     $this->exit->__invoke();
 }
Example #30
0
 /**
  * Handles a HTTP request
  *
  * @return void
  */
 public function handleRequest()
 {
     // Create the request very early so the Resource Management has a chance to grab it:
     $this->request = Request::createFromEnvironment();
     $this->response = new Response();
     $this->boot();
     $this->resolveDependencies();
     $this->request->injectSettings($this->settings);
     $this->router->setRoutesConfiguration($this->routesConfiguration);
     $actionRequest = $this->router->route($this->request);
     $this->securityContext->injectRequest($actionRequest);
     $this->dispatcher->dispatch($actionRequest, $this->response);
     $this->response->makeStandardsCompliant($this->request);
     $this->response->send();
     $this->bootstrap->shutdown('Runtime');
     $this->exit->__invoke();
 }