Example #1
1
 /**
  * Add a complex type by recursivly using all the class properties fetched via Reflection.
  *
  * @param  string $type Name of the class to be specified
  * @return string XSD Type for the given PHP type
  */
 public function addComplexType($type)
 {
     if (!class_exists($type)) {
         throw new \Zend\Soap\WSDL\Exception(sprintf('Cannot add a complex type %s that is not an object or where ' . 'class could not be found in \'DefaultComplexType\' strategy.', $type));
     }
     $dom = $this->getContext()->toDomDocument();
     $class = new \ReflectionClass($type);
     $complexType = $dom->createElement('xsd:complexType');
     $complexType->setAttribute('name', $type);
     $all = $dom->createElement('xsd:all');
     foreach ($class->getProperties() as $property) {
         if ($property->isPublic() && preg_match_all('/@var\\s+([^\\s]+)/m', $property->getDocComment(), $matches)) {
             /**
              * @todo check if 'xsd:element' must be used here (it may not be compatible with using 'complexType'
              * node for describing other classes used as attribute types for current class
              */
             $element = $dom->createElement('xsd:element');
             $element->setAttribute('name', $property->getName());
             $element->setAttribute('type', $this->getContext()->getType(trim($matches[1][0])));
             $all->appendChild($element);
         }
     }
     $complexType->appendChild($all);
     $this->getContext()->getSchema()->appendChild($complexType);
     $this->getContext()->addType($type);
     return "tns:{$type}";
 }
Example #2
1
 public static function run()
 {
     foreach (glob(app_path() . '/Http/Controllers/*.php') as $filename) {
         $file_parts = explode('/', $filename);
         $file = array_pop($file_parts);
         $file = rtrim($file, '.php');
         if ($file == 'Controller') {
             continue;
         }
         $controllerName = 'App\\Http\\Controllers\\' . $file;
         $controller = new $controllerName();
         if (isset($controller->exclude) && $controller->exclude === true) {
             continue;
         }
         $methods = [];
         $reflector = new \ReflectionClass($controller);
         foreach ($reflector->getMethods(\ReflectionMethod::IS_PUBLIC) as $rMethod) {
             // check whether method is explicitly defined in this class
             if ($rMethod->getDeclaringClass()->getName() == $reflector->getName()) {
                 $methods[] = $rMethod->getName();
             }
         }
         \Route::resource(strtolower(str_replace('Controller', '', $file)), $file, ['only' => $methods]);
     }
 }
Example #3
1
 /**
  * Add all the routes in the router in parameter
  * @param $router Router
  */
 public function generateRoute(Router $router)
 {
     foreach ($this->classes as $class) {
         $classMethods = get_class_methods($this->namespace . $class . 'Controller');
         $rc = new \ReflectionClass($this->namespace . $class . 'Controller');
         $parent = $rc->getParentClass();
         $parent = get_class_methods($parent->name);
         $className = $this->namespace . $class . 'Controller';
         foreach ($classMethods as $methodName) {
             if (in_array($methodName, $parent) || $methodName == 'index') {
                 continue;
             } else {
                 foreach (Router::getSupportedHttpMethods() as $httpMethod) {
                     if (strstr($methodName, $httpMethod)) {
                         continue 2;
                     }
                     if (in_array($methodName . $httpMethod, $classMethods)) {
                         $router->add('/' . strtolower($class) . '/' . $methodName, new $className(), $methodName . $httpMethod, $httpMethod);
                         unset($classMethods[$methodName . $httpMethod]);
                     }
                 }
                 $router->add('/' . strtolower($class) . '/' . $methodName, new $className(), $methodName);
             }
         }
         $router->add('/' . strtolower($class), new $className(), 'index');
     }
 }
 /**
  * {@inheritDoc}
  * @todo Same code exists in AnnotationDriver, should we re-use it somehow or not worry about it?
  */
 public function getAllClassNames()
 {
     if ($this->classNames !== null) {
         return $this->classNames;
     }
     if (!$this->paths) {
         throw MongoDBException::pathRequired();
     }
     $classes = array();
     $includedFiles = array();
     foreach ($this->paths as $path) {
         if (!is_dir($path)) {
             throw MongoDBException::fileMappingDriversRequireConfiguredDirectoryPath();
         }
         $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path), \RecursiveIteratorIterator::LEAVES_ONLY);
         foreach ($iterator as $file) {
             if (($fileName = $file->getBasename($this->fileExtension)) == $file->getBasename()) {
                 continue;
             }
             $sourceFile = realpath($file->getPathName());
             require_once $sourceFile;
             $includedFiles[] = $sourceFile;
         }
     }
     $declared = get_declared_classes();
     foreach ($declared as $className) {
         $rc = new \ReflectionClass($className);
         $sourceFile = $rc->getFileName();
         if (in_array($sourceFile, $includedFiles) && !$this->isTransient($className)) {
             $classes[] = $className;
         }
     }
     $this->classNames = $classes;
     return $classes;
 }
Example #5
0
 /**
  * contructor, creates node with reference to record and any options
  *
  * @param object $record                    instance of Doctrine_Record
  * @param array $options                    options
  */
 public function __construct(Doctrine_Record $record, $options)
 {
     $this->record = $record;
     $this->options = $options;
     // Make sure that the tree object of the root class is used in the case
     // of column aggregation inheritance (single table inheritance).
     $class = $record->getTable()->getComponentName();
     $thisTable = $record->getTable();
     $table = $thisTable;
     if ($thisTable->getOption('inheritanceMap')) {
         // Move up the hierarchy until we find the "subclasses" option. This option
         // MUST be set on the root class of the user's hierarchy that uses STI.
         while (!($subclasses = $table->getOption('subclasses'))) {
             $class = get_parent_class($class);
             $reflectionClass = new ReflectionClass($class);
             if ($reflectionClass->isAbstract()) {
                 continue;
             }
             if ($class == 'Doctrine_Record') {
                 throw new Doctrine_Node_Exception("No subclasses specified. You are " . "using Single Table Inheritance with NestedSet but you have " . "not specified the subclasses correctly. Make sure you use " . "setSubclasses() in the root class of your hierarchy.");
             }
             $table = $table->getConnection()->getTable($class);
         }
     }
     if ($thisTable !== $table) {
         $this->_tree = $table->getTree();
     } else {
         $this->_tree = $thisTable->getTree();
     }
 }
Example #6
0
 function callMethod()
 {
     $resultMethod = $this->createJSON();
     $apiName = stripcslashes($this->apiFunctionName[0]) . 'Api';
     $status = ApiConstants::$STATUS;
     if (file_exists(SERVER_DIR . 'app/Controller/Api/method/' . $apiName . '.php')) {
         $apiClass = ApiCore::getApiEngineByName($apiName);
         $apiReflection = new ReflectionClass($apiName);
         try {
             $functionName = $this->apiFunctionName[1];
             $apiReflection->getMethod($functionName);
             $response = ApiConstants::$RESPONSE;
             $res = $apiClass->{$functionName}($this->apiFunctionParams);
             if ($res == null) {
                 $resultMethod->{$status} = ApiConstants::$ERROR_NOT_FOUND_RECORD;
             } else {
                 if ($res->err == ApiConstants::$ERROR_PARAMS) {
                     $resultMethod->{$status} = ApiConstants::$ERROR_PARAMS;
                     $resultMethod->params = json_encode($apiFunctionParams);
                 } else {
                     $resultMethod->{$response} = $res;
                     $resultMethod->{$status} = ApiConstants::$ERROR_NO;
                 }
             }
         } catch (Exception $ex) {
             $resultMethod->errStr = $ex->getMessage();
         }
     } else {
         $resultMethod->errStr = 'Not found method';
         $resultMethod->{$status} = ApiConstants::$ERROR_NOT_FOUND_METHOD;
         $resultMethod->params = $this->apiFunctionParams;
     }
     return json_encode($resultMethod, JSON_UNESCAPED_UNICODE);
 }
Example #7
0
 /**
  * Call protected functions by making the visibitlity to public.
  *
  * @param string $name   method name
  * @param array  $params parameters for the invocation
  *
  * @return the output from the protected method.
  */
 private function _callProtectedFunction($name, $params)
 {
     $class = new ReflectionClass('PMA_DbSearch');
     $method = $class->getMethod($name);
     $method->setAccessible(true);
     return $method->invokeArgs($this->object, $params);
 }
Example #8
0
 /**
  * Tries to create a new router object for given component, returns NULL
  * if object not supported
  * 
  * @staticvar JComponentRouterInterface[] $cache
  * @param string $component Component name in format "com_xxx"
  * @return \JComponentRouterInterface
  */
 protected static function getComponentRouter($component)
 {
     static $cache = array();
     if (!array_key_exists($component, $cache)) {
         $router = null;
         $compName = ucfirst(substr($component, 4));
         $class = $compName . 'Router';
         if (class_exists($class)) {
             // Check if it supports the Joomla router interface, because
             // some components use classes with the same name causing
             // fatal error then (eg. EasyBlog)
             $reflection = new ReflectionClass($class);
             if (in_array('JComponentRouterInterface', $reflection->getInterfaceNames())) {
                 // Create the router object
                 $app = JFactory::getApplication();
                 $menu = $app->getMenu('site');
                 $router = new $class($app, $menu);
             }
         }
         // If router class not supported, create legacy router object (Joomla 3)
         if (!$router && class_exists('JComponentRouterLegacy')) {
             $router = new JComponentRouterLegacy($compName);
         }
         // Cache the router object
         $cache[$component] = $router;
     }
     return $cache[$component];
 }
Example #9
0
 protected static function getAccessibleMethod($class, $name)
 {
     $class = new ReflectionClass($class);
     $method = $class->getMethod($name);
     $method->setAccessible(true);
     return $method;
 }
 /**
  * Restores all static attributes in user-defined classes from this snapshot.
  *
  * @param Snapshot $snapshot
  */
 public function restoreStaticAttributes(Snapshot $snapshot)
 {
     $current = new Snapshot($snapshot->blacklist(), false, false, false, false, true, false, false, false, false);
     $newClasses = array_diff($current->classes(), $snapshot->classes());
     unset($current);
     foreach ($snapshot->staticAttributes() as $className => $staticAttributes) {
         foreach ($staticAttributes as $name => $value) {
             $reflector = new ReflectionProperty($className, $name);
             $reflector->setAccessible(true);
             $reflector->setValue($value);
         }
     }
     foreach ($newClasses as $className) {
         $class = new \ReflectionClass($className);
         $defaults = $class->getDefaultProperties();
         foreach ($class->getProperties() as $attribute) {
             if (!$attribute->isStatic()) {
                 continue;
             }
             $name = $attribute->getName();
             if ($snapshot->blacklist()->isStaticAttributeBlacklisted($className, $name)) {
                 continue;
             }
             if (!isset($defaults[$name])) {
                 continue;
             }
             $attribute->setAccessible(true);
             $attribute->setValue($defaults[$name]);
         }
     }
 }
 public static function getMethod($obj, $name)
 {
     $class = new \ReflectionClass($obj);
     $method = $class->getMethod($name);
     $method->setAccessible(true);
     return $method;
 }
 public static function setUpBeforeClass()
 {
     $reflect = new \ReflectionClass(__CLASS__);
     self::$directory = @tempnam(sys_get_temp_dir(), $reflect->getShortName() . '-');
     @unlink(self::$directory);
     @mkdir(self::$directory);
 }
Example #13
0
 function __construct()
 {
     global $adb, $log, $current_user;
     echo "<table width=80% align=center border=1>";
     $reflector = new ReflectionClass(get_class($this));
     $fname = basename($reflector->getFileName(), '.php');
     $cburs = $adb->pquery('select * from vtiger_cbupdater where filename=? and classname=?', array($fname, get_class($this)));
     if ($cburs and $adb->num_rows($cburs) > 0) {
         // it exists, we load it
         $cbu = $adb->fetch_array($cburs);
         $this->cbupdid = $cbu['cbupdaterid'];
         $this->cbupd_no = $cbu['cbupd_no'];
         $this->author = $cbu['author'];
         $this->filename = $cbu['filename'];
         $this->classname = $cbu['classname'];
         $this->execstate = $cbu['execstate'];
         $this->systemupdate = $cbu['systemupdate'] == '1' ? true : false;
         $this->perspective = (isset($cbu['perspective']) and $cbu['perspective'] == '1') ? true : false;
         $this->blocked = (isset($cbu['blocked']) and $cbu['blocked'] == '1') ? true : false;
         $this->execdate = $cbu['execdate'];
         $this->updError = false;
     } else {
         // it doesn't exist, we fail because it MUST exist
         $this->sendError();
     }
 }
 public static function doLog($logmethod, array $data, &$output)
 {
     $log = new Logger('ezperflogger');
     // constructor args for the specific handler can be set via ini
     /// @todo how to create resources instead?
     foreach (eZPerfLoggerINI::variable('MonologSettings', 'LogHandlers') as $handlerName) {
         $handlerClass = 'Monolog\\Handler\\' . $handlerName . "Handler";
         if (eZPerfLoggerINI::hasVariable('MonologSettings', 'LogHandler_' . $handlerName)) {
             $r = new ReflectionClass($handlerClass);
             $handler = $r->newInstanceArgs(eZPerfLoggerINI::variable('MonologSettings', 'LogHandler_' . $handlerName));
         } else {
             $handler = new $handlerClass();
         }
         $log->pushHandler($handler);
     }
     // the default severity level: taken from config file
     $level = (int) eZPerfLoggerINI::variable('MonologSettings', 'SeverityLevel');
     // either coalesce messages or not: taken from config file
     if (eZPerfLoggerINI::variable('MonologSettings', 'Coalescevariables') == 'enabled') {
         /// @todo allow via ini file the specification of custom formatters?
         $msg = array();
         foreach ($data as $varname => $value) {
             $msg[] = "{$varname}: {$value}";
         }
         $log->addRecord($level, implode(', ', $msg));
     } else {
         foreach ($data as $varname => $value) {
             $log->addRecord($level, "{$varname}: {$value}");
         }
     }
 }
Example #15
0
 public function configureService($serviceName, array $settings)
 {
     $this->app[$serviceName] = $this->app->share(function (WebApplication $app) use($settings) {
         $class = new \ReflectionClass($settings['class']);
         $arguments = array();
         $deps = isset($settings['deps']) ? $settings['deps'] : array();
         foreach ($deps as $key) {
             if (is_string($key) && preg_match('/^%(.+)%$/', $key, $matches)) {
                 $key = $matches[1];
                 $value = $this->app[$key];
             } else {
                 $value = $key;
             }
             $arguments[] = $value;
         }
         $instance = $class->newInstanceArgs($arguments);
         if (isset($settings['set'])) {
             foreach ($settings['set'] as $field => $value) {
                 if (is_string($value) && preg_match('/^%(.+)%$/', $value, $matches)) {
                     $value = $matches[1];
                     $value = $this->app[$value];
                 }
                 $method = 'set' . ucwords(preg_replace('/_+/', ' ', strtolower($field)));
                 $method = preg_replace('/\\s+/', '', $method);
                 $instance->{$method}($value);
             }
         }
         return $instance;
     });
 }
 public function callConstructor()
 {
     $parent = new \ReflectionClass(parent::class);
     if ($parent->getConstructor()) {
         parent::__construct();
     }
 }
Example #17
0
 /**
  * Auto-Generate an alias for an entity.
  *
  * @param string      $alias
  * @param \DC_General $dc
  *
  * @return string
  * @throws Exception
  */
 public static function generateAlias($alias, \DC_General $dc)
 {
     /** @var EntityInterface $entity */
     $entity = $dc->getCurrentModel()->getEntity();
     $autoAlias = false;
     // Generate alias if there is none
     if (!strlen($alias)) {
         $autoAlias = true;
         if ($entity->__has('title')) {
             $alias = standardize($entity->getTitle());
         } elseif ($entity->__has('name')) {
             $alias = standardize($entity->getName());
         } else {
             return '';
         }
     }
     $entityClass = new \ReflectionClass($entity);
     $keys = explode(',', $entityClass->getConstant('KEY'));
     $entityManager = EntityHelper::getEntityManager();
     $queryBuilder = $entityManager->createQueryBuilder();
     $queryBuilder->select('COUNT(e.' . $keys[0] . ')')->from($entityClass->getName(), 'e')->where($queryBuilder->expr()->eq('e.alias', ':alias'))->setParameter(':alias', $alias);
     static::extendQueryWhereId($queryBuilder, $dc->getCurrentModel()->getID(), $entity);
     $query = $queryBuilder->getQuery();
     $duplicateCount = $query->getResult(Query::HYDRATE_SINGLE_SCALAR);
     // Check whether the news alias exists
     if ($duplicateCount && !$autoAlias) {
         throw new Exception(sprintf($GLOBALS['TL_LANG']['ERR']['aliasExists'], $alias));
     }
     // Add ID to alias
     if ($duplicateCount && $autoAlias) {
         $alias .= '-' . $dc->getCurrentModel()->getID();
     }
     return $alias;
 }
Example #18
0
 function query($sql, $params = [])
 {
     if (!$params) {
         return $this->pquery($sql);
     }
     $stmt = $this->mysqli->prepare($sql);
     $stmt or $this->_sqlError($this->mysqli->error, $sql);
     $ref = new ReflectionClass('mysqli_stmt');
     $method = $ref->getMethod('bind_param');
     $method->invokeArgs($stmt, $this->_refValues($params));
     $rs = $stmt->execute();
     $result = $stmt->get_result();
     if ($result) {
         while ($row = $result->fetch_assoc()) {
             $data[] = $row;
         }
         return isset($data) ? $data : null;
     } else {
         if ($this->mysqli->insert_id) {
             return $this->mysqli->insert_id;
         }
         if ($this->mysqli->affected_rows) {
             return $this->mysqli->affected_rows;
         }
     }
 }
Example #19
0
 /**
  * {@inheritdoc}
  */
 public function getProperties($class, array $context = array())
 {
     try {
         $reflectionClass = new \ReflectionClass($class);
     } catch (\ReflectionException $reflectionException) {
         return;
     }
     $reflectionProperties = $reflectionClass->getProperties();
     $properties = array();
     foreach ($reflectionProperties as $reflectionProperty) {
         if ($reflectionProperty->isPublic()) {
             $properties[$reflectionProperty->name] = true;
         }
     }
     foreach ($reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $reflectionMethod) {
         $propertyName = $this->getPropertyName($reflectionMethod->name, $reflectionProperties);
         if (!$propertyName || isset($properties[$propertyName])) {
             continue;
         }
         if (!preg_match('/^[A-Z]{2,}/', $propertyName)) {
             $propertyName = lcfirst($propertyName);
         }
         $properties[$propertyName] = true;
     }
     return array_keys($properties);
 }
Example #20
0
 public function executeIndex()
 {
     //perlu di rapihkan
     $field_name = $this->name;
     $reflection = new ReflectionClass($this->model . 'Peer');
     $method = $reflection->getMethod('doSelect');
     $c = new Criteria();
     $filter_field = strtoupper($this->filter_field);
     $filter_content = $this->filter_content;
     if (!empty($filter_field)) {
         if ($this->case == 'equal') {
             $c->add($reflection->getConstant($filter_field), $filter_content, Criteria::EQUAL);
         } else {
             if ($this->case == 'not_equal') {
                 $c->add($reflection->getConstant($filter_field), $filter_content, Criteria::NOT_EQUAL);
             }
         }
     }
     $order_column = $this->order_column;
     $order_type = $this->order_type;
     if (!empty($order_column)) {
         if ($order_type == 'desc') {
             $c->addDescendingOrderByColumn($order_column);
         } else {
             $c->addAscendingOrderByColumn($order_column);
         }
     }
     $reg_info = $method->invoke($method, $c);
     $this->data = $reg_info;
     $this->name = $field_name;
     $this->desc = !isset($this->desc) ? 'Name' : $this->desc;
 }
Example #21
0
 /**
  * Generates and checks presenter class name.
  * @param  string  presenter name
  * @return string  class name
  * @throws InvalidPresenterException
  */
 public function getPresenterClass(&$name)
 {
     if (isset($this->cache[$name])) {
         return $this->cache[$name];
     }
     if (!is_string($name) || !Nette\Utils\Strings::match($name, '#^[a-zA-Z\\x7f-\\xff][a-zA-Z0-9\\x7f-\\xff:]*\\z#')) {
         throw new InvalidPresenterException("Presenter name must be alphanumeric string, '{$name}' is invalid.");
     }
     $class = $this->formatPresenterClass($name);
     if (!class_exists($class)) {
         throw new InvalidPresenterException("Cannot load presenter '{$name}', class '{$class}' was not found.");
     }
     $reflection = new \ReflectionClass($class);
     $class = $reflection->getName();
     if (!$reflection->implementsInterface('Nette\\Application\\IPresenter')) {
         throw new InvalidPresenterException("Cannot load presenter '{$name}', class '{$class}' is not Nette\\Application\\IPresenter implementor.");
     } elseif ($reflection->isAbstract()) {
         throw new InvalidPresenterException("Cannot load presenter '{$name}', class '{$class}' is abstract.");
     }
     $this->cache[$name] = $class;
     if ($name !== ($realName = $this->unformatPresenterClass($class))) {
         trigger_error("Case mismatch on presenter name '{$name}', correct name is '{$realName}'.", E_USER_WARNING);
         $name = $realName;
     }
     return $class;
 }
Example #22
0
 public function store($object)
 {
     if (!is_object($object)) {
         throw new Exception('Invalid Entity. Should be object');
     }
     $table = $this->getTableName($object);
     $values = array();
     $reflector = new ReflectionClass($object);
     foreach ($reflector->getProperties() as $prop) {
         $comment = $prop->getDocComment();
         if (strpos($comment, '@primary') || strpos($comment, '@field')) {
             $values[$prop->getName()] = $prop->getValue($object);
         }
     }
     $keys = array_keys($values);
     if (is_null($object->id)) {
         $str = '`' . implode('`, `', $keys) . '`';
         $str2 = ':' . implode(', :', $keys);
         $sql = "INSERT INTO {$table} ({$str}) VALUES ({$str2})";
         $this->execute($sql, $values);
         $object->id = $this->lastInsertId();
     } else {
         $str = '';
         foreach ($keys as $k) {
             if ($k == 'id') {
                 continue;
             }
             $str .= " {$k}=:{$k},";
         }
         $str = rtrim($str, ',');
         $sql = "UPDATE {$table} SET {$str} WHERE id = :id";
         $this->execute($sql, $values);
     }
     return $object;
 }
Example #23
0
 /**
  * Generic getter/setter
  * 
  * @param string $name Name of property
  * @param array  $args Function arguments
  *
  * @throws \Exception
  * 
  * @return void 
  */
 public function __call($name, $args = array())
 {
     // This call method is only for accessors
     if (strlen($name) > 3) {
         // Get the property
         $property = substr($name, 3, strlen($name));
         // All properties will be camelcase, make first, letter lowercase
         $property[0] = strtolower($property[0]);
         // Accessor method
         $accessor = substr($name, 0, 3);
         // Only run code for setters and getters
         if (in_array($accessor, array('set', 'get'))) {
             // Check if property is publically accessible
             if (property_exists($this, $property)) {
                 // Only allow protected variables to be accessed
                 $reflector = new \ReflectionClass(get_class($this));
                 $prop = $reflector->getProperty($property);
                 if ($prop->isPrivate()) {
                     throw new \Exception(sprintf('Unable to %s, property is private: %s:%s', $accessor, __CLASS__, $property));
                 }
             } else {
                 throw new \Exception('Unknown method called: ' . __CLASS__ . ':' . $name);
             }
             switch ($accessor) {
                 case 'set':
                     $this->{$property} = $args[0];
                     return $this;
                 case 'get':
                     return $this->{$property};
             }
         }
     }
 }
Example #24
0
 /**
  * Call protected/private method of a class.
  *
  * @param object &$object    Instantiated object that we will run method on.
  * @param string $methodName Method name to call
  * @param array  $parameters Array of parameters to pass into method.
  *
  * @return mixed Method return.
  */
 public function invokeMethod(&$object, $methodName, array $parameters = array())
 {
     $reflection = new \ReflectionClass(get_class($object));
     $method = $reflection->getMethod($methodName);
     $method->setAccessible(true);
     return $method->invokeArgs($object, $parameters);
 }
 /**
  * Call a protected method to test it.
  *
  * @param object $obj  The instance of the object.
  * @param string $name The protected method to call.
  * @param array  $args The arguments to pass to the method.
  *
  * @return mixed
  */
 public function callProtectedMethod($obj, $name, array $args)
 {
     $class = new \ReflectionClass($obj);
     $method = $class->getMethod($name);
     $method->setAccessible(true);
     return $method->invokeArgs($obj, $args);
 }
 /**
  * Get an internal property
  * @param  string $source
  * @return mixed
  */
 public function getInternal($source)
 {
     $reflection = new \ReflectionClass($this->resolver);
     $property = $reflection->getProperty($source);
     $property->setAccessible(true);
     return $property->getValue($this->resolver);
 }
Example #27
0
 /**
  * Get Global Application CMS accessibility scope.
  *
  * @access public
  * @static
  * @uses   Core\Config()
  *
  * @return array
  */
 public static function getAccessibilityScope()
 {
     $scope = glob(Core\Config()->paths('mode') . 'controllers' . DIRECTORY_SEPARATOR . '*.php');
     $builtin_scope = array('CMS\\Controllers\\CMS');
     $builtin_actions = array();
     $accessibility_scope = array();
     foreach ($builtin_scope as $resource) {
         $builtin_actions = array_merge($builtin_actions, get_class_methods($resource));
     }
     $builtin_actions = array_filter($builtin_actions, function ($action) {
         return !in_array($action, array('create', 'show', 'edit', 'delete', 'export'), true);
     });
     foreach ($scope as $resource) {
         $resource = basename(str_replace('.php', '', $resource));
         if ($resource !== 'cms') {
             $controller_name = '\\CMS\\Controllers\\' . $resource;
             $controller_class = new \ReflectionClass($controller_name);
             if (!$controller_class->isInstantiable()) {
                 continue;
             }
             /* Create instance only if the controller class is instantiable */
             $controller_object = new $controller_name();
             if ($controller_object instanceof CMS\Controllers\CMS) {
                 $accessibility_scope[$resource] = array_diff(get_class_methods($controller_name), $builtin_actions);
                 array_push($accessibility_scope[$resource], 'index');
                 foreach ($accessibility_scope[$resource] as $key => $action_with_acl) {
                     if (in_array($action_with_acl, $controller_object->skipAclFor, true)) {
                         unset($accessibility_scope[$resource][$key]);
                     }
                 }
             }
         }
     }
     return $accessibility_scope;
 }
 /**
  * {@inheritdoc}
  */
 public function create() : ResourceNameCollection
 {
     $classes = [];
     $includedFiles = [];
     if ($this->decorated) {
         foreach ($this->decorated->create() as $resourceClass) {
             $classes[$resourceClass] = true;
         }
     }
     foreach ($this->paths as $path) {
         $iterator = new \RegexIterator(new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path, \FilesystemIterator::SKIP_DOTS), \RecursiveIteratorIterator::LEAVES_ONLY), '/^.+\\.php$/i', \RecursiveRegexIterator::GET_MATCH);
         foreach ($iterator as $file) {
             $sourceFile = $file[0];
             if (!preg_match('(^phar:)i', $sourceFile)) {
                 $sourceFile = realpath($sourceFile);
             }
             require_once $sourceFile;
             $includedFiles[$sourceFile] = true;
         }
     }
     $declared = get_declared_classes();
     foreach ($declared as $className) {
         $reflectionClass = new \ReflectionClass($className);
         $sourceFile = $reflectionClass->getFileName();
         if (isset($includedFiles[$sourceFile]) && $this->reader->getClassAnnotation($reflectionClass, ApiResource::class)) {
             $classes[$className] = true;
         }
     }
     return new ResourceNameCollection(array_keys($classes));
 }
 /**
  * Get object property.
  *
  * @param object $object
  * @param string $property
  */
 protected function getPropertyValue(&$object, $property)
 {
     $reflection = new \ReflectionClass(get_class($object));
     $reflectionProperty = $reflection->getProperty($property);
     $reflectionProperty->setAccessible(true);
     return $reflectionProperty->getValue($object);
 }
 function procesar()
 {
     toba::logger_ws()->debug('Servicio Llamado: ' . $this->info['basica']['item']);
     toba::logger_ws()->set_checkpoint();
     set_error_handler('toba_logger_ws::manejador_errores_recuperables', E_ALL);
     $this->validar_componente();
     //-- Pide los datos para construir el componente, WSF no soporta entregar objetos creados
     $clave = array();
     $clave['proyecto'] = $this->info['objetos'][0]['objeto_proyecto'];
     $clave['componente'] = $this->info['objetos'][0]['objeto'];
     list($tipo, $clase, $datos) = toba_constructor::get_runtime_clase_y_datos($clave, $this->info['objetos'][0]['clase'], false);
     agregar_dir_include_path(toba_dir() . '/php/3ros/wsf');
     $opciones_extension = toba_servicio_web::_get_opciones($this->info['basica']['item'], $clase);
     $wsdl = strpos($_SERVER['REQUEST_URI'], "?wsdl") !== false;
     $sufijo = 'op__';
     $metodos = array();
     $reflexion = new ReflectionClass($clase);
     foreach ($reflexion->getMethods() as $metodo) {
         if (strpos($metodo->name, $sufijo) === 0) {
             $servicio = substr($metodo->name, strlen($sufijo));
             $prefijo = $wsdl ? '' : '_';
             $metodos[$servicio] = $prefijo . $metodo->name;
         }
     }
     $opciones = array();
     $opciones['serviceName'] = $this->info['basica']['item'];
     $opciones['classes'][$clase]['operations'] = $metodos;
     $opciones = array_merge($opciones, $opciones_extension);
     $this->log->debug("Opciones del servidor: " . var_export($opciones, true), 'toba');
     $opciones['classes'][$clase]['args'] = array($datos);
     toba::logger_ws()->set_checkpoint();
     $service = new WSService($opciones);
     $service->reply();
     $this->log->debug("Fin de servicio web", 'toba');
 }