Пример #1
0
 /**
  * Do this execute.
  *
  * @return  mixed
  */
 protected function doExecute()
 {
     /** @var ConvertOperator $operator */
     $operator = $this->container->get('operator.factory')->getOperator('convert');
     $replace = ArrayHelper::flatten($this->replace);
     // Flip replace array because we want to convert template.
     $replace = array_flip($replace);
     foreach ($replace as &$val) {
         $val = StringHelper::quote($val, $operator->getTagVariable());
     }
     // Flip src and dest because we want to convert template.
     $src = $this->config['dir.src'];
     $dest = $this->config['dir.dest'];
     if (is_dir($dest)) {
         // Remove dir first
         Folder::delete($dest);
     }
     $operator->copy($src, $dest, $replace);
 }
Пример #2
0
 /**
  * testFlatten
  *
  * @return  void
  *
  * @covers  Windwalker\Utilities\ArrayHelper::flatten
  * @since   1.0
  */
 public function testFlatten()
 {
     $array = array('flower' => 'sakura', 'olive' => 'peace', 'pos1' => array('sunflower' => 'love'), 'pos2' => array('cornflower' => 'elegant'));
     $flatted = ArrayHelper::flatten($array);
     $this->assertEquals($flatted['pos1.sunflower'], 'love');
     $flatted = ArrayHelper::flatten($array, '/');
     $this->assertEquals($flatted['pos1/sunflower'], 'love');
 }
Пример #3
0
 /**
  * appendWhereOr
  *
  * @param   mixed|callable $conditions
  *
  * @return  static
  */
 public function orHaving($conditions)
 {
     $query = $this->db->getQuery(true);
     if (is_callable($conditions)) {
         $conditions($query);
         $having = $query->having->getElements();
         foreach ($query->getBounded() as $key => $bound) {
             $this->bind($key, $bound->value, $bound->dataType, $bound->lengeh, $bound->driverOptions);
         }
     } else {
         $having = (array) $conditions;
         $having = ArrayHelper::flatten($having);
     }
     $having = $query->element('()', $having, ' OR ');
     return $this->having($having);
 }