예제 #1
0
파일: Path.php 프로젝트: appcia/webwork
 /**
  * Set path template
  *
  * @param string $content Path template
  *
  * @return $this
  */
 public function setContent($content)
 {
     if ($content !== '/') {
         $content = rtrim($content, '/');
     }
     parent::setContent($content);
     return $this;
 }
예제 #2
0
파일: Logger.php 프로젝트: appcia/webwork
 /**
  * Write log message
  *
  * @param string $message Message
  * @param string $level   Level
  *
  * @return $this
  * @throws \InvalidArgumentException
  */
 public function write($message, $level)
 {
     if (empty($message)) {
         throw new \InvalidArgumentException(sprintf("Logger write error. Message cannot be empty."));
     }
     if (!in_array($level, self::$levels)) {
         throw new \InvalidArgumentException(sprintf("Logger write error. Invalid level '%s'", $level));
     }
     $date = new \DateTime('now');
     $this->template->set('level', mb_strtoupper($level))->set('message', trim($message))->set('date', $date->format('Y-m-d H:i:s.u'));
     if ($this->callback !== null && is_callable($this->callback)) {
         call_user_func($this->callback, $this->template);
     }
     $text = $this->template->render();
     $this->file->append($text);
     return $this;
 }
예제 #3
0
파일: Type.php 프로젝트: appcia/webwork
 /**
  * @param string $path
  *
  * @return string
  */
 protected function compilePath($path)
 {
     $params = $this->resource->getParams();
     $tpl = new Template($path);
     $tpl->setParams($params, File::WILDCARD);
     $path = $tpl->render();
     return $path;
 }
예제 #4
0
파일: Form.php 프로젝트: appcia/webwork
 /**
  * Group fields by specified pattern
  * Creates multi-dimensional tree in which each level corresponds to pattern parameter
  * Leafs are form fields
  *
  * @param string $template Field name template
  *
  * @return array
  * @throws \InvalidArgumentException
  */
 public function groupFields($template)
 {
     $template = new Template($template);
     $result = array();
     foreach ($this->fields as $name => $field) {
         $match = array();
         if (preg_match($template->getRegExp(), $name, $match)) {
             unset($match[0]);
             $match[] = $field;
             $fields = Arr::nest($match);
             $result = array_replace_recursive($result, $fields);
         }
     }
     return $result;
 }