/** * Builds the Data Object * * @return AbstractSimpleObject */ public function create() { $dataObjectType = $this->_getDataObjectType(); $dataObject = $this->objectFactory->create($dataObjectType, ['data' => $this->data]); $this->data = []; return $dataObject; }
/** * Create an instance of an input value which holds a real value. * * @param string $stringExpression the input string as typed in the console. * e.g. '1' is integeter value 1 * '"1"' is string '1' * * @return \Box\TestScribe\Input\InputValue */ public static function createValue($stringExpression) { $objectFactoryObj = new ObjectFactory(); $converterObj = $objectFactoryObj->getStringToInputValueConverter(); $inputValue = $converterObj->getValue($stringExpression); return $inputValue; }
/** * @public * */ public static function getInstance() { if (self::$instance === null) { self::$instance = new ObjectFactory(); } return self::$instance; }
public function __construct($id = NULL) { // Get basic class information from database and store in object if (!$this->_className) { $this->_className = get_class($this); } // $pA = array('s', $this->_className); $result = ObjectFactory::getTableDetails($this->_className); if ($result->getRows()) { // Store class information in protected fields if (!isset($this->_table)) { $this->_table = DB::clean($result->tableName); } $this->_pKey = DB::clean($result->pKey); // Get fields from database $result = ObjectFactory::getDetails($this->_className); $this->addFields($result); } if ($id) { $this->setID($id); } // If autoFill is true then get data from the DB (outside ID if so can // retrieve a blank record) if ($this->_autoFill) { $this->getFromDB(); } }
/** * @param ExtensibleDataInterface $dataObject * @param string $getterMethodName * @param string $methodName * @param array $value * @param string $interfaceName * @return $this */ protected function setComplexValue(ExtensibleDataInterface $dataObject, $getterMethodName, $methodName, array $value, $interfaceName) { if ($interfaceName == null) { $interfaceName = get_class($dataObject); } $returnType = $this->objectProcessor->getMethodReturnType($interfaceName, $getterMethodName); if ($this->typeProcessor->isTypeSimple($returnType)) { $dataObject->{$methodName}($value); return $this; } if ($this->typeProcessor->isArrayType($returnType)) { $type = $this->typeProcessor->getArrayItemType($returnType); $objects = []; foreach ($value as $arrayElementData) { $object = $this->objectFactory->create($type, []); $this->populateWithArray($object, $arrayElementData, $type); $objects[] = $object; } $dataObject->{$methodName}($objects); return $this; } if (is_subclass_of($returnType, '\\Magento\\Framework\\Api\\ExtensibleDataInterface')) { $object = $this->objectFactory->create($returnType, []); $this->populateWithArray($object, $value, $returnType); } else { if (is_subclass_of($returnType, '\\Magento\\Framework\\Api\\ExtensionAttributesInterface')) { $object = $this->extensionFactory->create(get_class($dataObject), $value); } else { $object = $this->objectFactory->create($returnType, $value); } } $dataObject->{$methodName}($object); return $this; }
/** * Builds the Data Object * * @return AbstractSimpleObject */ public function create() { $dataObjectType = $this->_getDataObjectType(); $dataObject = $this->objectFactory->create($dataObjectType, ['builder' => $this]); $this->_data = array(); return $dataObject; }
function create($class_name, $args = array()) { ObjectFactory :: _includeClassFile($class_name); $handle =& new Handle($class_name, $args); return Handle :: resolve($handle); }
/** * Constructor. Parameters are: * - writeFactory : ObjectFactory::getObjectFromSpec parameters yeilding BagOStuff. * This object will be used for writes (e.g. the master DB). * - readFactory : ObjectFactory::getObjectFromSpec parameters yeilding BagOStuff. * This object will be used for reads (e.g. a slave DB). * * @param array $params * @throws InvalidArgumentException */ public function __construct($params) { parent::__construct($params); if (!isset($params['writeFactory'])) { throw new InvalidArgumentException(__METHOD__ . ': the "writeFactory" parameter is required'); } if (!isset($params['readFactory'])) { throw new InvalidArgumentException(__METHOD__ . ': the "readFactory" parameter is required'); } $this->writeStore = $params['writeFactory'] instanceof BagOStuff ? $params['writeFactory'] : ObjectFactory::getObjectFromSpec($params['writeFactory']); $this->readStore = $params['readFactory'] instanceof BagOStuff ? $params['readFactory'] : ObjectFactory::getObjectFromSpec($params['readFactory']); }
public function __construct($reactionID) { $dbMgr = new DatabaseManager(true); $objectData = $dbMgr->getReactionData($reactionID); $this->reactionID = $objectData['reactionID']; $this->reactionType = $objectData['reactionType']; $this->inputs = $dbMgr->getReactionInputs($this->reactionID); $objectFactory = new ObjectFactory(); foreach ($this->inputs as $input) { $inputType = $objectFactory->create(ObjectFactory::TYPE, $input['typeID']); $inputVolume = $inputType->getVolume() * $input['inputQty']; $this->inputVolume += $inputVolume; } $this->output = $objectFactory->create(ObjectFactory::TYPE, $objectData['typeID']); $this->outputQty = $objectData['outputQty']; $this->outputVolume = $this->outputQty * $this->output->getVolume(); $this->reactionName = $this->output->getName(); if ($this->reactionType == 3) { $this->reactionName += " Alchemy"; } $dbMgr = null; }
/** * @covers ObjectFactory::getObjectFromSpec */ public function testClosureExpansionEnabled() { $obj = ObjectFactory::getObjectFromSpec(array('class' => 'ObjectFactoryTest_Fixture', 'args' => array(function () { return 'unwrapped'; }), 'closure_expansion' => true)); $this->assertInternalType('string', $obj->args[0]); $this->assertSame('unwrapped', $obj->args[0]); $obj = ObjectFactory::getObjectFromSpec(array('class' => 'ObjectFactoryTest_Fixture', 'args' => array(function () { return 'unwrapped'; }))); $this->assertInternalType('string', $obj->args[0]); $this->assertSame('unwrapped', $obj->args[0]); }
/** * Constructor. Parameters are: * - writeFactory : ObjectFactory::getObjectFromSpec array yeilding BagOStuff. * This object will be used for writes (e.g. the master DB). * - readFactory : ObjectFactory::getObjectFromSpec array yeilding BagOStuff. * This object will be used for reads (e.g. a replica DB). * * @param array $params * @throws InvalidArgumentException */ public function __construct($params) { parent::__construct($params); if (!isset($params['writeFactory'])) { throw new InvalidArgumentException(__METHOD__ . ': the "writeFactory" parameter is required'); } if (!isset($params['readFactory'])) { throw new InvalidArgumentException(__METHOD__ . ': the "readFactory" parameter is required'); } $opts = ['reportDupes' => false]; // redundant $this->writeStore = $params['writeFactory'] instanceof BagOStuff ? $params['writeFactory'] : ObjectFactory::getObjectFromSpec($opts + $params['writeFactory']); $this->readStore = $params['readFactory'] instanceof BagOStuff ? $params['readFactory'] : ObjectFactory::getObjectFromSpec($opts + $params['readFactory']); $this->attrMap = $this->mergeFlagMaps([$this->readStore, $this->writeStore]); }
/** * {@inheritdoc} */ public function create() { if ($this->getDataType() == self::TYPE_DATA_MODEL) { /** @var \Magento\Framework\Model\AbstractExtensibleModel $dataObject */ $dataObject = $this->objectFactory->create($this->_getDataObjectType(), ['data' => $this->data]); $dataObject->setDataChanges(true); } else { $dataObjectType = $this->_getDataObjectType(); $dataObject = $this->objectFactory->create($dataObjectType, ['builder' => $this]); } if ($dataObject instanceof \Magento\Framework\Object) { $dataObject->setDataChanges(true); } $this->data = []; return $dataObject; }
/** * Fetch a CentralIdLookup * @param string|null $providerId Provider ID from $wgCentralIdLookupProviders * @return CentralIdLookup|null */ public static function factory($providerId = null) { global $wgCentralIdLookupProviders, $wgCentralIdLookupProvider; if ($providerId === null) { $providerId = $wgCentralIdLookupProvider; } if (!array_key_exists($providerId, self::$instances)) { self::$instances[$providerId] = null; if (isset($wgCentralIdLookupProviders[$providerId])) { $provider = ObjectFactory::getObjectFromSpec($wgCentralIdLookupProviders[$providerId]); if ($provider instanceof CentralIdLookup) { $provider->providerId = $providerId; self::$instances[$providerId] = $provider; } } } return self::$instances[$providerId]; }
/** * $params include: * - caches: A numbered array of either ObjectFactory::getObjectFromSpec * arrays yeilding BagOStuff objects or direct BagOStuff objects. * If using the former, the 'args' field *must* be set. * The first cache is the primary one, being the first to * be read in the fallback chain. Writes happen to all stores * in the order they are defined. However, lock()/unlock() calls * only use the primary store. * - replication: Either 'sync' or 'async'. This controls whether writes * to secondary stores are deferred when possible. Async writes * require setting 'asyncHandler'. HHVM register_postsend_function() function. * Async writes can increase the chance of some race conditions * or cause keys to expire seconds later than expected. It is * safe to use for modules when cached values: are immutable, * invalidation uses logical TTLs, invalidation uses etag/timestamp * validation against the DB, or merge() is used to handle races. * @param array $params * @throws InvalidArgumentException */ public function __construct($params) { parent::__construct($params); if (empty($params['caches']) || !is_array($params['caches'])) { throw new InvalidArgumentException(__METHOD__ . ': "caches" parameter must be an array of caches'); } $this->caches = []; foreach ($params['caches'] as $cacheInfo) { if ($cacheInfo instanceof BagOStuff) { $this->caches[] = $cacheInfo; } else { if (!isset($cacheInfo['args'])) { // B/C for when $cacheInfo was for ObjectCache::newFromParams(). // Callers intenting this to be for ObjectFactory::getObjectFromSpec // should have set "args" per the docs above. Doings so avoids extra // (likely harmless) params (factory/class/calls) ending up in "args". $cacheInfo['args'] = [$cacheInfo]; } $this->caches[] = ObjectFactory::getObjectFromSpec($cacheInfo); } } $this->asyncWrites = isset($params['replication']) && $params['replication'] === 'async' && is_callable($this->asyncHandler); }
/** * Create an array of AuthenticationProviders from an array of ObjectFactory specs * @param string $class * @param array[] $specs * @return AuthenticationProvider[] */ protected function providerArrayFromSpecs($class, array $specs) { $i = 0; foreach ($specs as &$spec) { $spec = ['sort2' => $i++] + $spec + ['sort' => 0]; } unset($spec); usort($specs, function ($a, $b) { return (int) $a['sort'] - (int) $b['sort'] ?: $a['sort2'] - $b['sort2']; }); $ret = []; foreach ($specs as $spec) { $provider = \ObjectFactory::getObjectFromSpec($spec); if (!$provider instanceof $class) { throw new \RuntimeException("Expected instance of {$class}, got " . get_class($provider)); } $provider->setLogger($this->logger); $provider->setManager($this); $provider->setConfig($this->config); $id = $provider->getUniqueId(); if (isset($this->allAuthenticationProviders[$id])) { throw new \RuntimeException("Duplicate specifications for id {$id} (classes " . get_class($provider) . ' and ' . get_class($this->allAuthenticationProviders[$id]) . ')'); } $this->allAuthenticationProviders[$id] = $provider; $ret[$id] = $provider; } return $ret; }
/** * @covers ObjectFactory::constructClassInstance * @expectedException InvalidArgumentException */ public function testNamedArgs() { $args = ['foo' => 1, 'bar' => 2, 'baz' => 3]; $obj = ObjectFactory::constructClassInstance('ObjectFactoryTestFixture', $args); }
function & createObject($object_path, $args = array())//fix? { include_once(LIMB_DIR . '/core/ObjectFactory.class.php'); return ObjectFactory :: create($object_path, $args); }
<?php require_once 'include/session_setup.php'; $time = microtime(); $time = explode(' ', $time); $time = $time[1] + $time[0]; $start = $time; $scriptName = basename($_SERVER['PHP_SELF']); $options = array("r" => $_SESSION['params']['r'], "s" => $_SESSION['params']['s'], "g" => $_SESSION['params']['g'], "sy" => $_SESSION['params']['sy'], "i" => $_SESSION['params']['i'], "f" => $_SESSION['params']['f'], "o" => $_SESSION['params']['o'], "t" => $_SESSION['params']['t']); $dbMgr = new DatabaseManager(true); $objectFactory = new ObjectFactory(); $formBuilder = new FormBuilder(); $datetime = $dbMgr->getLastTimestamp(time(), 300); ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <?php if (isset($argArray['configure'])) { echo "<title>Reaction Toolkit Configuration</title>"; } else { echo "<title>Reaction Toolkit Dashboard</title>"; } ?> <link rel="stylesheet" type="text/css" href="include/css/bootstrap.css"> <link rel="stylesheet" type="text/css" href="include/css/toolkit.css"> <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.js"></script> <script type="text/javascript">
/** * @public * */ public function getObject($ClassName, $AliasName = '') { // Object Factory instanzieren $this->ObjectFactory = ObjectFactory::getInstance(); // Wenn das Objekt Debug bereits registriert wurde, // gibt mit die Intance auf dieses Objekt if (FL_TRACE) { if (TRACE_SYSTEM) { if ($this->ObjectFactory->isObjectRegistered('Debug')) { $this->debug = $this->ObjectFactory->getObject('Debug', ''); $this->setTrace($ClassName, $AliasName); } } } /* * call object factory */ $this->ObjectInstance = $this->ObjectFactory->getObject($ClassName, $AliasName); // return ObjectInstance from ObjectFactory return $this->ObjectInstance; }
/** * Get the available SessionProviders * @return SessionProvider[] */ protected function getProviders() { if ($this->sessionProviders === null) { $this->sessionProviders = array(); foreach ($this->config->get('SessionProviders') as $spec) { $provider = \ObjectFactory::getObjectFromSpec($spec); $provider->setLogger($this->logger); $provider->setConfig($this->config); $provider->setManager($this); if (isset($this->sessionProviders[(string) $provider])) { throw new \UnexpectedValueException("Duplicate provider name \"{$provider}\""); } $this->sessionProviders[(string) $provider] = $provider; } } return $this->sessionProviders; }
/** * Create a new object to replace this stub object. * @return object */ public function _newObject() { return ObjectFactory::getObjectFromSpec(array('class' => $this->class, 'args' => $this->params, 'closure_expansion' => false)); }
/** * @covers ObjectFactory::constructClassInstance * @dataProvider provideConstructClassInstance */ public function testConstructClassInstance($args) { $obj = ObjectFactory::constructClassInstance('ObjectFactoryTestFixture', $args); $this->assertSame($args, $obj->args); }
// five edits // Caching $wgObjectCaches['redis'] = array('class' => 'RedisBagOStuff', 'servers' => array('127.0.0.1:6379'), 'persistent' => true); $wgMainCacheType = 'redis'; // Avoid user request serialization and other slowness $wgSessionCacheType = 'redis'; $wgSessionsInObjectCache = true; // Jobqueue $wgJobTypeConf['default'] = array('class' => 'JobQueueRedis', 'daemonized' => true, 'redisServer' => '127.0.0.1', 'redisConfig' => array('connectTimeout' => 2, 'compression' => 'gzip')); $wgJobQueueAggregator = array('class' => 'JobQueueAggregatorRedis', 'redisServers' => array('127.0.0.1'), 'redisConfig' => array('connectTimeout' => 2)); $wgLegacyJavaScriptGlobals = false; $wgEnableJavaScriptTest = true; require_once __DIR__ . '/settings.d/wikis/CommonSettings.php'; // XXX: Is this a bug in core? (ori-l, 27-Aug-2013) $wgHooks['GetIP'][] = function (&$ip) { if (PHP_SAPI === 'cli') { $ip = '127.0.0.1'; } return true; }; // Execute all jobs via standalone jobrunner service rather than // piggybacking them on web requests. $wgJobRunRate = 0; // Bug 73037: handmade gzipping sometimes makes error messages impossible to see in HHVM $wgDisableOutputCompression = true; // Allow 'vagrant' password. $wgPasswordPolicy['policies']['sysop']['MinimalPasswordLength'] = 7; $wgPasswordPolicy['policies']['bureaucrat']['MinimalPasswordLength'] = 7; // Ensure that full LoggerFactory configuration is applied MediaWiki\Logger\LoggerFactory::registerProvider(ObjectFactory::getObjectFromSpec($wgMWLoggerDefaultSpi));
/** * @param string $class * @param array $args * @return object * @deprecated 1.25 Use ObjectFactory::getObjectFromSpec() instead */ public static function newObj($class, $args = array()) { wfDeprecated(__METHOD__, '1.25'); return ObjectFactory::getObjectFromSpec(array('class' => $class, 'args' => $args, 'closure_expansion' => false)); }
/** * Find the object with a given name and return it (or NULL) * * @param string $name Special page name, may be localised and/or an alias * @return SpecialPage|null SpecialPage object or null if the page doesn't exist */ public static function getPage($name) { list($realName, ) = self::resolveAlias($name); if (isset(self::$pageObjectCache[$realName])) { return self::$pageObjectCache[$realName]; } $specialPageList = self::getPageList(); if (isset($specialPageList[$realName])) { $rec = $specialPageList[$realName]; if (is_callable($rec)) { // Use callback to instantiate the special page $page = call_user_func($rec); } elseif (is_string($rec)) { $className = $rec; $page = new $className(); } elseif (is_array($rec)) { $className = array_shift($rec); // @deprecated, officially since 1.18, unofficially since forever wfDeprecated("Array syntax for \$wgSpecialPages is deprecated ({$className}), " . "define a subclass of SpecialPage instead.", '1.18'); $page = ObjectFactory::getObjectFromSpec(['class' => $className, 'args' => $rec, 'closure_expansion' => false]); } elseif ($rec instanceof SpecialPage) { $page = $rec; // XXX: we should deep clone here } else { $page = null; } self::$pageObjectCache[$realName] = $page; if ($page instanceof SpecialPage) { return $page; } else { // It's not a classname, nor a callback, nor a legacy constructor array, // nor a special page object. Give up. wfLogWarning("Cannot instantiate special page {$realName}: bad spec!"); return null; } } else { return null; } }
/** * Create a new object to replace this stub object. * @return object */ public function _newObject() { $params = $this->factory ? ['factory' => $this->factory] : ['class' => $this->class]; return ObjectFactory::getObjectFromSpec($params + ['args' => $this->params, 'closure_expansion' => false]); }
<?php require_once 'include/session_setup.php'; $time = microtime(); $time = explode(' ', $time); $time = $time[1] + $time[0]; $start = $time; $scriptName = basename($_SERVER['PHP_SELF']); $dbMgr = new DatabaseManager(true); $objectFactory = new ObjectFactory(); $formBuilder = new FormBuilder(); if (isset($argArray['re'])) { $reactionID = $argArray['re']; $reaction = $objectFactory->create(ObjectFactory::REACTION, $reactionID); } if (isset($argArray['c']) && $reaction->getReactionType() == 2) { $chain = 1; $chainStr = "Reaction Chain"; } else { $chain = 0; $chainStr = "Reaction"; } if (isset($argArray['d'])) { $datetime = $dbMgr->getLastTimestamp($argArray['d'], 300); $dateChanged = 1; } else { $datetime = $dbMgr->getLastTimestamp(time(), 300); } $options = array("r" => $_SESSION['params']['r'], "c" => $chain, "s" => $_SESSION['params']['s'], "g" => $_SESSION['params']['g'], "sy" => $_SESSION['params']['sy'], "i" => $_SESSION['params']['i'], "f" => $_SESSION['params']['f'], "o" => $_SESSION['params']['o'], "st" => $_SESSION['params']['st'], "b" => $_SESSION['params']['b'], "t" => $_SESSION['params']['t']); ?> <!DOCTYPE html>
/** * Prepare page to be rendered into PDF. * * @todo Don't forget to close all current graphics operations (like path drawing) * * @param \Zend\Pdf\ObjectFactory $objFactory * @throws \Zend\Pdf\Exception */ public function render(ObjectFactory $objFactory) { $this->flush(); if ($objFactory === $this->_objFactory) { // Page is already attached to the document. return; } if ($this->_attached) { throw new Exception('Page is attached to one documen, but rendered in context of another.'); /** * @todo Page cloning must be implemented here instead of exception. * PDF objects (ex. fonts) can be shared between pages. * Thus all referenced objects, which can be modified, must be cloned recursively, * to avoid producing wrong object references in a context of source PDF. */ //... } else { $objFactory->attach($this->_objFactory); } }
<meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" type="text/css" href="include/css/bootstrap.css"> <link rel="stylesheet" type="text/css" href="include/css/toolkit.css"> <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.js"></script> </head> <body role="document"> <?php include 'include/pages/navbar.php'; ?> <div class="container-fluid"> <div class="page-header"> <h1 class="center">Reaction Input Lookup</h1> </div> <?php require_once 'include/session_setup.php'; $objectFactory = new ObjectFactory(); $formBuilder = new FormBuilder(); $scriptName = basename($_SERVER['PHP_SELF']); if (isset($_POST['re'])) { $reactionID = $_POST['re']; $reaction = $objectFactory->create(ObjectFactory::REACTION, $reactionID); $reactionType = $reaction->getReactionType(); if ($reactionType == 3) { $reactionName = $reaction->getOutput()->getName() . " Alchemy"; } else { $reactionName = $reaction->getOutput()->getName(); } $inputs = $reaction->getInputs(); ?> <div class="center"> <form class="form-inline" style="display:inline" method="post" action="<?php
/** * Construct a HTMLForm object for given display type. May return a HTMLForm subclass. * * @param string $displayFormat * @param mixed $arguments... Additional arguments to pass to the constructor. * @return HTMLForm */ public static function factory($displayFormat) { $arguments = func_get_args(); array_shift($arguments); switch ($displayFormat) { case 'vform': return ObjectFactory::constructClassInstance(VFormHTMLForm::class, $arguments); case 'ooui': return ObjectFactory::constructClassInstance(OOUIHTMLForm::class, $arguments); default: /** @var HTMLForm $form */ $form = ObjectFactory::constructClassInstance(HTMLForm::class, $arguments); $form->setDisplayFormat($displayFormat); return $form; } }