Example #1
0
 /**
  * @test
  */
 public function canReset()
 {
     $data = ['one' => ['two' => ['a' => 111, 'b' => 222]]];
     // can set and get a simple value
     $arrayAccessor = new ArrayAccessor($data);
     $this->assertSame(111, $arrayAccessor->get('one:two:a'));
     $this->assertSame(222, $arrayAccessor->get('one:two:b'));
     $arrayAccessor->reset('one:two:a');
     $this->assertSame(null, $arrayAccessor->get('one:two:a'));
     $this->assertSame(222, $arrayAccessor->get('one:two:b'));
 }
 /**
  * Gets the parent TypoScript Object from a given TypoScript path.
  *
  * In the context of an frontend content element the path plugin.tx_solr is
  * merged recursive with overrule with the content element specific typoscript
  * settings, like plugin.tx_solr_PiResults_Results, and possible flex form settings
  * (depends on the solr plugin).
  *
  * Example: plugin.tx_solr.index.queue.tt_news.fields.content
  * returns $GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_solr.']['index.']['queue.']['tt_news.']['fields.']['content.']
  * which is a SOLR_CONTENT cObj.
  *
  * @param string $path TypoScript path
  * @return array The TypoScript object defined by the given path
  * @throws InvalidArgumentException
  */
 public function getObjectByPath($path)
 {
     if (substr($path, -1) !== '.') {
         $path = rtrim($path, '.');
         $path = substr($path, 0, strrpos($path, '.') + 1);
     }
     if (!is_string($path)) {
         throw new InvalidArgumentException('Parameter $path is not a string', 1325627243);
     }
     return $this->configurationAccess->get($path);
 }
Example #3
0
 /**
  * This can be used to start a new sub request, e.g. for a faceted search.
  *
  * @param bool $onlyPersistentArguments
  * @return SearchRequest
  */
 public function getCopyForSubRequest($onlyPersistentArguments = true)
 {
     $argumentsArray = $this->argumentsAccessor->getData();
     if ($onlyPersistentArguments) {
         $arguments = new ArrayAccessor();
         foreach ($this->persistentArgumentsPaths as $persistentArgumentPath) {
             if ($this->argumentsAccessor->has($persistentArgumentPath)) {
                 $arguments->set($persistentArgumentPath, $this->argumentsAccessor->get($persistentArgumentPath));
             }
         }
         $argumentsArray = $arguments->getData();
     }
     return new SearchRequest($argumentsArray);
 }
Example #4
0
 /**
  * @test
  */
 public function resetIsRemovingSubNodesAndEmptyNodes()
 {
     $data = ['one' => ['two' => ['a' => 111, 'b' => 222], 'three' => 333]];
     // can set and get a simple value
     $arrayAccessor = new ArrayAccessor($data);
     $this->assertSame(111, $arrayAccessor->get('one:two:a'));
     $this->assertSame(222, $arrayAccessor->get('one:two:b'));
     $arrayAccessor->reset('one:two');
     $this->assertSame(null, $arrayAccessor->get('one:two:a'));
     $this->assertSame(null, $arrayAccessor->get('one:two:b'));
     $this->assertSame(null, $arrayAccessor->get('one:two'));
     $this->assertSame(333, $arrayAccessor->get('one:three'));
 }