示例#1
0
 /**
  * @return PHPoole
  */
 public function getPHPoole()
 {
     $messageCallback = function ($code, $message = '', $itemsCount = 0, $itemsMax = 0, $verbose = true) {
         switch (true) {
             case $code == 'CREATE' || $code == 'CONVERT' || $code == 'GENERATE' || $code == 'RENDER' || $code == 'COPY':
                 $this->wlAnnonce($message);
                 break;
             case $code == 'CREATE_PROGRESS' || $code == 'CONVERT_PROGRESS' || $code == 'GENERATE_PROGRESS' || $code == 'RENDER_PROGRESS' || $code == 'COPY_PROGRESS':
                 if ($itemsCount > 0 && $verbose !== false) {
                     $this->wlDone(sprintf("\r  (%u/%u) %s", $itemsCount, $itemsMax, $message));
                     break;
                 }
                 $this->wlDone("  {$message}");
                 break;
         }
     };
     if (!$this->phpoole instanceof PHPoole) {
         if (!file_exists($this->getPath() . '/' . self::CONFIG_FILE)) {
             $this->wlError('Config file (phpoole.yml) not found!');
             exit(2);
         }
         try {
             $options = (new Yaml())->parse(file_get_contents($this->getPath() . '/' . self::CONFIG_FILE));
             $this->phpoole = new PHPoole($options, $messageCallback);
             $this->phpoole->setSourceDir($this->getPath());
             $this->phpoole->setDestDir($this->getPath());
         } catch (\Exception $e) {
             $this->wlError($e->getMessage());
             exit(2);
         }
     }
     return $this->phpoole;
 }