Пример #1
0
 public function route(Request $request)
 {
     $path = new StringValue($request->path());
     if ($path->starts('/api/')) {
         Api\Router::create('/api/')->route($request);
         return;
     }
     if ($path->starts('/')) {
     }
 }
Пример #2
0
 private function processToken()
 {
     $optionFound = null;
     if (($optionName = $this->token->afterStarts(Runner::OPTION_NAME)) && isset($this->def->byName[$optionName])) {
         $optionFound = $this->def->byName[$optionName];
     } elseif (($optionName = $this->token->afterStarts(Runner::OPTION_SHORT)) && isset($this->def->byShortName[$optionName])) {
         $optionFound = $this->def->byShortName[$optionName];
     }
     if ($this->variadicStarted && $optionFound) {
         if (empty($this->variadicValues)) {
             throw new Exception('Unexpected option, value required', Exception::VALUE_REQUIRED);
         }
         $this->finishVariadic();
     }
     if (!empty($this->def->requiredArguments) && $optionFound) {
         throw new Exception('Unexpected option, argument required', Exception::ARGUMENT_REQUIRED);
     }
     if ($this->variadicStarted) {
         $this->continueVariadic();
         return;
     }
     if ($this->valueRequired) {
         if ($optionFound) {
             throw new Exception('Unexpected option, value required', Exception::VALUE_REQUIRED);
         }
         $this->valueRequired();
         return;
     }
     if (!empty($this->def->requiredArguments)) {
         $this->option = array_shift($this->def->requiredArguments);
         $this->processOption();
         return;
     }
     if ($optionFound) {
         $this->option = $optionFound;
         $this->processOption();
         return;
     }
     if ($this->def->optionalArguments) {
         $this->option = array_shift($this->def->optionalArguments);
         $this->processOption();
         return;
     }
     throw new CliException('Unexpected token: ' . $this->token, CliException::UNKNOWN_OPTION);
 }
Пример #3
0
 private function pushItem($item)
 {
     if ($this->itemIndex >= 16) {
         $this->phpTable = trim($this->phpTable);
         $this->phpTable .= "\n";
         $this->itemIndex = 0;
     }
     ++$this->itemIndex;
     $item = new StringValue($item);
     if ($item->starts('\\x') || $item->starts('\\n')) {
         $this->phpTable .= '"' . $item . '", ';
         $this->nonQuestionBoxFound = true;
     } else {
         // TODO check if this hack should be removed for chinese letters
         if ($item->value === '[?] ') {
             $item->value = '[?]';
         }
         //
         if ($item->value !== '[?]') {
             $this->nonQuestionBoxFound = true;
         }
         $this->phpTable .= "'" . str_replace(array('\\', '\''), array('\\\\', '\\\''), $item) . "', ";
     }
 }
Пример #4
0
 public function route()
 {
     $path = new StringValue($this->request->path());
     switch (true) {
         case $path->starts('/?') || '/' === $path->value:
             IndexController::ActionIndex();
             break;
         case $path->value === '/albums':
             AlbumController::create($this->request)->actionIndex();
             break;
         case $path->starts('/albums/details'):
             AlbumController::create($this->request)->actionDetails();
             break;
         case $path->starts('/albums/create'):
             AlbumController::create($this->request)->actionCreate();
             break;
         case $path->starts('/albums/upload/receive'):
             AlbumController::create($this->request)->actionUploadReceive();
             break;
         case $path->starts('/auth/vk'):
             AuthController::create($this->request)->oauthEndPoint();
             break;
         case $path->value === '/auth/register':
             AuthController::create($this->request)->actionRegister();
             break;
         case $path->value === '/auth/sign-in':
             AuthController::create($this->request)->actionSignIn();
             break;
         case $path->value === '/auth/register/receive':
             AuthController::create($this->request)->actionRegisterReceive();
             break;
         case $path->value === '/upload':
             UploadController::create($this->request)->indexAction();
             break;
         case $path->starts('/upload/receive'):
             UploadController::create($this->request)->receiveAction();
             break;
         default:
             IndexController::NotFoundAction();
             break;
     }
 }
Пример #5
0
 public function performAction()
 {
     if (!file_exists($this->path)) {
         $this->response->error(new Expression('Path ? not found', $this->path));
         return;
     }
     if (StringValue::create($this->path)->ends('.tar.gz')) {
         $filename = $this->path;
         $reader = new Reader($filename);
         $reader->setReadContents(false);
         $reader->setBuffer(1000000);
         $count = 0;
         foreach ($reader as $record) {
             if (in_array($record['type'], array(Reader::REGULAR, Reader::AREGULAR), TRUE)) {
                 //var_dump($record['filename']);
                 ++$count;
             }
         }
         $reader->setReadContents(true);
         $this->count = $count;
         foreach ($reader as $record) {
             if (in_array($record['type'], array(Reader::REGULAR, Reader::AREGULAR), TRUE)) {
                 $this->addData($this->path . ':' . trim($record['filename']), $record['contents']);
             }
         }
     } else {
         $profiles = array();
         if (is_dir($this->path)) {
             if ($handle = opendir($this->path)) {
                 while (false !== ($entry = readdir($handle))) {
                     if ($entry != "." && $entry != "..") {
                         $profiles[] = $this->path . '/' . $entry;
                     }
                 }
                 closedir($handle);
             }
         } else {
             $profiles[] = $this->path;
         }
         $this->count = count($profiles);
         foreach ($profiles as $filename) {
             $this->addData($filename, file_get_contents($filename));
         }
     }
     if (!$this->noSquash) {
         $this->saveSymbolStats();
         $this->saveRelatedStats();
     }
     $this->response->success('All done!');
     $this->response->addContent(new Info('Run ID ' . $this->runInstance->id . ' added'));
 }