コード例 #1
0
ファイル: PHP5ObjectBuilder.php プロジェクト: halfer/Meshing
 /**
  * Validates the current table to make sure that it won't
  * result in generated code that will not parse.
  *
  * This method may emit warnings for code which may cause problems
  * and will throw exceptions for errors that will definitely cause
  * problems.
  */
 protected function validateModel()
 {
     parent::validateModel();
     $table = $this->getTable();
     // Check to see whether any generated foreign key names
     // will conflict with column names.
     $colPhpNames = array();
     $fkPhpNames = array();
     foreach ($table->getColumns() as $col) {
         $colPhpNames[] = $col->getPhpName();
     }
     foreach ($table->getForeignKeys() as $fk) {
         $fkPhpNames[] = $this->getFKPhpNameAffix($fk, $plural = false);
     }
     $intersect = array_intersect($colPhpNames, $fkPhpNames);
     if (!empty($intersect)) {
         throw new EngineException("One or more of your column names for [" . $table->getName() . "] table conflict with foreign key names (" . implode(", ", $intersect) . ")");
     }
     // Check foreign keys to see if there are any foreign keys that
     // are also matched with an inversed referencing foreign key
     // (this is currently unsupported behavior)
     // see: http://propel.phpdb.org/trac/ticket/549
     foreach ($table->getForeignKeys() as $fk) {
         if ($fk->isMatchedByInverseFK()) {
             throw new EngineException("The 1:1 relationship expressed by foreign key " . $fk->getName() . " is defined in both directions; Propel does not currently support this (if you must have both foreign key constraints, consider adding this constraint with a custom SQL file.)");
         }
     }
 }
コード例 #2
0
ファイル: ObjectBuilder.php プロジェクト: DevSKolb/FLOWLite
 /**
  * @public 
  *
  */
 public static function getInstance()
 {
     if (self::$instance === null) {
         self::$instance = new ObjectBuilder();
     }
     return self::$instance;
 }
 protected function initialize($object, &$result)
 {
     parent::initialize($object, $result);
     $realObject = $this->getRealObject($object);
     $this->identityMap->bind($realObject, $result);
     return $this;
 }
コード例 #4
0
ファイル: Abstract.Component.php プロジェクト: markhj/bytes
 /**
  * Instantiate a controller from the component scope
  *
  * @final
  * @access public
  * @param string $ControllerName
  * @param string $Method
  * @param array $Context
  * @uses Component::GetDirectory
  * @uses ObjectBuilder::CreateController
  * @return mixed
  */
 public final function Controller(string $ControllerName, string $Method, array $Context = [])
 {
     /* ------------------------------------------------------------------------------------------------------
           EXECUTE
        ------------------------------------------------------------------------------------------------------ */
     $Controller = $this->ObjectBuilder->CreateController($this->GetDirectory(), $ControllerName, ['Method' => $Method]);
     /* ------------------------------------------------------------------------------------------------------
           TEST CONTROLLER
        ------------------------------------------------------------------------------------------------------ */
     // We need to make sure the controller has the requested method
     if (!method_exists($Controller, $Method)) {
         throw new ComponentException(sprintf('Method %s not found in controller %s', $Method, $ControllerName));
     }
     /* ------------------------------------------------------------------------------------------------------
           CREATE
        ------------------------------------------------------------------------------------------------------ */
     return $Controller->{$Method}((new \Bytes\GlobalScope())->SetRoute(isset($Context['Route']) ? (string) $Context['Route'] : ''), isset($Context['ErrorHandler']) ? $Context['Exception'] : Null, isset($Context['ErrorHandler']) ? $this->__InjectionContainer->Retrieve('Environment') : Null, isset($Context['ErrorHandler']) ? $this->__InjectionContainer->Retrieve('Header') : Null);
 }
コード例 #5
0
 /**
  * Gets the package for the [base] object classes.
  * @return     string
  */
 public function getPackage()
 {
     return parent::getPackage() . ".om";
 }
コード例 #6
0
 /**
  * Override method to return child package, if specified.
  * @return     string
  */
 public function getPackage()
 {
     return $this->child->getPackage() ? $this->child->getPackage() : parent::getPackage();
 }
コード例 #7
0
ファイル: ObjectFactory.php プロジェクト: DevSKolb/FLOWLite
 /**
  * @public
  * create object over ObjectBuilder
  */
 private function createObject($ClassName, $AliasName = '')
 {
     // Object Builder instanzieren
     $this->ObjectBuilder = ObjectBuilder::getInstance();
     // Name of Object
     $this->NameOfObject = $this->getObjectName($ClassName, $AliasName);
     // Object über Object Builder anfordern
     $this->ObjectInstance = $this->ObjectBuilder->createObject($ClassName);
     // set ObjectInstance in ObjectManager
     $this->set($this->NameOfObject, $this->ObjectInstance);
     // Destroy Object Instance über Object Builder
     $this->ObjectBuilder->destroy($this->ObjectInstance);
     // return ObjectInstance from ObjectManager
     return $this->get($this->NameOfObject);
 }
コード例 #8
0
ファイル: ObjectBuilderTest.php プロジェクト: seytar/psx
 public function testGetObjectWithoutConstructor()
 {
     $builder = new ObjectBuilder(new Container());
     $stdClass = $builder->getObject('stdClass');
     $this->assertInstanceof('stdClass', $stdClass);
 }
コード例 #9
0
ファイル: Application.php プロジェクト: markhj/bytes
 /**
  * Starts the application
  *
  * @access public
  * @param string $URI URI for the router to compare against
  * @param callable $Callback
  * @return mixed Whatever comes out of $Callback
  */
 public function Start(string $URI, callable $Callback)
 {
     /* ------------------------------------------------------------------------------------------------------
           INITIALIZE
        ------------------------------------------------------------------------------------------------------ */
     $InjectionContainer = new InjectionContainer();
     $ObjectBuilder = new ObjectBuilder();
     $InjectionContainer->Attach('Environment', $this->Environment);
     $InjectionContainer->Attach('Header', $this->Header);
     $ObjectBuilder->SetInjectionContainer($InjectionContainer);
     $ObjectBuilder->SetHooksContainer($this->HooksContainer);
     $ObjectBuilder->SetImplementations($this->Implementations);
     // Populate triggers/hook for the application object
     $this->__Options->PopulateTriggers($this->HooksContainer, $ObjectBuilder);
     /* ------------------------------------------------------------------------------------------------------
           LOAD COMPONENTS
        ------------------------------------------------------------------------------------------------------ */
     // Iterate over all preloaded components
     foreach ($this->Components as $I => $ComponentName) {
         // Use the object builder to create the component and work with the router and environment
         $Component = $ObjectBuilder->CreateImplementation($ComponentName, 'Component');
         // Initialize the component (create its routes, etc.)
         $Component->Initialize($this->Router);
         // Store the component for later reference
         $this->Components[basename($ComponentName)] = $Component;
     }
     /* ------------------------------------------------------------------------------------------------------
           FIND ROUTE + EXECUTE CONTROLLER
        ------------------------------------------------------------------------------------------------------ */
     try {
         // Find information on controller and method, using the Router's Match method
         $Route = $this->Router->Match($URI);
         // If no route is found, we'll invoke a 404 error
         if (!$Route) {
             throw new Exception('Not Found', 404);
         }
         // Retrieve output from the controller's requested method
         $ComponentId = basename($Route['Component']);
         $Output = $this->Components[$ComponentId]->Controller((string) $Route['Controller'], (string) $Route['Method'], ['Route' => $URI]);
         // If we successfully get to this point, we store the output
         // This enables us to use it both inside the custom callback method, as well as
         // in other methods, such as Application::Render
         $this->ControllerOutput = $Output;
     } catch (\Exception $E) {
         // Load environment
         $Env = $this->Environment();
         // In case of exception, we'll look to the router, and see if it requests to use
         // a custom error handle
         if ($this->AssignedErrorHandler) {
             $Handle = 'ERROR/' . (string) $Route['ErrorHandle'];
             $ErrorHandlerComponent = basename($this->AssignedErrorHandler['Location']);
             $ErrorHandler = $this->Components[$ErrorHandlerComponent];
             $ErrorRoute = $this->Router->Match($Handle);
             $ErrorController = (string) $ErrorRoute['Controller'];
             $ErrorMethod = (string) $ErrorRoute['Method'];
             if (!$ErrorRoute) {
                 $ErrorController = 'Index';
                 $ErrorMethod = 'Default';
             }
             $Output = $ErrorHandler->Controller($ErrorController, $ErrorMethod, ['ErrorHandler' => True, 'Exception' => $E]);
             $this->ControllerOutput = $Output;
         } else {
             // If there's no custom error handle and no default, we'll do a fallback to a simple JSON message
             // (JSON applied, if Application::Render is used)
             $this->ControllerOutput = ['Error' => $E->getMessage()];
         }
     }
     /* ------------------------------------------------------------------------------------------------------
           RETURN
        ------------------------------------------------------------------------------------------------------ */
     return $Callback($this, $this->ControllerOutput);
 }