public function getFileAndPutWithStoreKeeper($key, $dirToSearch = null)
 {
     try {
         $fileInfo = $this->checkFileExists($key, $dirToSearch);
         StoreKeeper::putFileInfoWithStoreKeeper($key, $fileInfo);
     } catch (\Exception $e) {
         throw $e;
     }
     return $this->saveInStore($key, new $fileInfo['fullFileName']());
 }
예제 #2
0
 /**
  * Heart of the application.
  * Optimus takes you through application as per url.
  *
  * @throws \LP\Framework\Exceptions\RouteNotFoundException
  * @throws \Lp\Framework\Exceptions\DuplicateFileNameException
  */
 public function letsRoll()
 {
     try {
         $goto = Router::reduce(Request::howYouWantToGo(), Request::whereYouWantToGo());
         $classArray = array();
         if ($controller = StoreKeeper::getFromStore(StoreKeeper::STORE_TYPE_CONTROLLER, $goto['path']['controller'])) {
             $classArray = array($controller, $goto['path']['action']);
         } elseif (empty($classArray)) {
             $classArray = array(new IndexController(), self::DEFAULT_ACTION);
         }
         call_user_func_array($classArray, $goto['params']);
     } catch (RouteNotFoundException $rnfe) {
         var_dump($rnfe);
     } catch (DuplicateFileNameException $dfne) {
         var_dump($dfne);
     } catch (\Exception $e) {
         var_dump($e);
     }
 }
 /**
  * Common load function.
  *
  * @param null $name name of the class to load.
  * @param int $storeType type of class store.
  * @return null|\stdClass $object
  * @throws \Exception
  */
 private function load($name = null, $storeType)
 {
     $object = null;
     try {
         $object = StoreKeeper::getFromStore($storeType, $name);
     } catch (DuplicateFileNameException $dfne) {
         throw new \Exception("File not found {$dfne}");
     } catch (\Exception $e) {
         throw $e;
     }
     if (is_null($object) || !$object instanceof BaseModel) {
         throw new \Exception("Class {$name} not found");
     }
     return $object;
 }