/** * Overload object factory for Singleton * * @return bConfig|null|static */ public static function create() { if (self::$_instance === null) { self::$_instance = parent::create(func_get_args()); self::$_instance->initialize(); } return self::$_instance; }
protected static function getInstanceDirect($className) { if (empty(self::$instances[$className])) { $entity = new static(); $entity->initialize($className); $entity->postInitialize(); self::$instances[$className] = $entity; } return self::$instances[$className]; }
/** * Return a instance of himself. * * Sometime only one helper of a specific type must be set for a request so the same instance can be return * if the same request helper is used. This method should always be used instead of the constructor. * * @param RequestHelper $requestHelper * @return static */ public static function instantiate(RequestHelper $requestHelper) { $objectHash = spl_object_hash($requestHelper); if (static::isSingleInstance()) { if (isset(static::$instances[$objectHash][static::getName()])) { return static::$instances[$objectHash][static::getName()]; } } $instance = new static(); $instance->requestHelper = $requestHelper; $instance->initialize(); $requestHelper->getEventDispatcher()->dispatch(RequestHelper::EVENT_NEW_HELPER, new RequestHelperEvent($requestHelper, array('helper' => $instance))); if (static::isSingleInstance()) { static::$instances[$objectHash][static::getName()] = $instance; } return $instance; }
/** * Creates the session driver with provided options * * If no driver is provided the Server driver with default options * will be created. * * @param null|string $driver * @param array $options * * @throws InvalidArgumentException If the class does not exists or if * class does not implements the SessionDriverInterface. * * @return SessionDriverInterface */ public static function create($driver = null, $options = []) { $driver = $driver ?: self::DRIVER_SERVER; $session = new static(['driver' => $driver, 'options' => $options]); return $session->initialize(); }
public static function run(AccountInterface $account, $report = null) { //-- use a ReportingInterface if (!is_a($report, ReportingInterface::class)) { $report = new Report(); } $scan = new static($account, $report); $scan->initialize(); $scan->determineBaseline(); $scan->scanDirectory(); $scan->handleDeletedFiles(); $scan->complete(); $scan->report->addScan($scan); $scan->report->report(); return $scan; }
public static function readyUp() { $instance = new static(); $instance->initialize(); return $instance; }
/** * Return an instance of the command by passing an InputResult. * This method is used when creating commands from a factory. * * @param InputResult $inputResult * @return static */ public static function createFromInput(InputResult $inputResult) { $instance = new static(); $instance->initialize($inputResult); return $instance; }