idx
int64
0
241k
question
stringlengths
64
6.21k
target
stringlengths
5
803
240,300
public function resetPK ( $ val = FALSE ) { if ( $ val === FALSE ) { $ this -> reset ( static :: $ pk ) ; } else { $ this -> attributeValues [ static :: $ pk ] = $ val ; } }
Reset the primary key to default or set to a specific value
240,301
public function cast ( $ name , $ val ) { if ( is_null ( $ val ) ) { return $ val ; } switch ( @ static :: $ attributes [ $ name ] [ 'type' ] ) { case self :: TYPE_INT : $ val = ( int ) $ val ; break ; case self :: TYPE_STRING : $ val = ( string ) $ val ; break ; case self :: TYPE_BOOL : $ val = ( bool ) $ val ; break ...
Cast a value for an attribute datatype
240,302
public function create ( $ exclude = array ( ) , & $ db = FALSE ) { $ create = $ this -> createColumnsAndValues ( $ exclude ) ; if ( $ db === FALSE ) { $ db = & $ this -> getDbMaster ( ) ; } $ query = $ db -> prepare ( ' INSERT INTO `' . static :: $ dbTable . '` (' . $ create [ 'columns' ] . ') VALUES ( ' . $ create ...
Create object in the database
240,303
public function createOrUpdate ( $ update , $ exclude = array ( ) , & $ db = FALSE ) { $ create = $ this -> createColumnsAndValues ( $ exclude ) ; $ updateVals = NULL ; foreach ( $ update as $ column => $ value ) { $ updateVals .= ', `' . $ column . '` = ' ; $ updateVals .= is_array ( $ value ) ? $ value [ 0 ] : $ valu...
Create or update an object in the database if it already exists
240,304
private function createColumnsAndValues ( & $ exclude ) { if ( ! $ this -> attributeHasValue ( static :: $ pk ) ) { $ exclude [ ] = static :: $ pk ; } $ columns = NULL ; $ values = NULL ; foreach ( static :: $ attributes as $ name => $ attribute ) { if ( in_array ( $ name , $ exclude ) ) { continue ; } if ( ! $ this ->...
Generate create query columns and values
240,305
private function transformValue ( $ name , $ attribute , & $ exclude ) { $ value = $ this -> iget ( $ name ) ; if ( is_null ( $ value ) || ( isset ( $ attribute [ 'null' ] ) && $ attribute [ 'null' ] && $ value === '' ) ) { $ this -> iset ( $ name , NULL ) ; $ value = 'NULL' ; $ exclude [ ] = $ name ; } else { switch (...
Apply any attribute value transformations for SQL query
240,306
private function bindAttributes ( & $ query , $ exclude = array ( ) ) { foreach ( array_keys ( static :: $ attributes ) as $ name ) { if ( in_array ( $ name , $ exclude ) ) { continue ; } $ query -> bindValue ( ':' . $ name , $ this -> iget ( $ name ) ) ; } }
Bind object attribute values to the query
240,307
private function executeCreateUpdateQuery ( & $ query ) { try { $ query -> execute ( ) ; return TRUE ; } catch ( \ PDOException $ e ) { switch ( $ e -> getCode ( ) ) { case 23000 : if ( preg_match ( '/Duplicate entry \'(.*?)\' for key \'(.*?)\'/' , $ e -> getMessage ( ) , $ match ) ) { $ name = $ this -> attributeExist...
Execute create or update query and cope with an exception
240,308
public function read ( $ pkValue = FALSE , & $ db = FALSE ) { try { if ( $ pkValue !== FALSE ) { $ this -> iset ( static :: $ pk , $ pkValue ) ; } if ( $ db === FALSE ) { $ db = & $ this -> getDbSlave ( ) ; } $ query = $ db -> prepare ( ' SELECT * FROM `' . static :: $ dbTable . '` WHERE ' . static :: $ pk . ' = :p...
Read an object from the database populating the object attributes
240,309
public function readAttribute ( $ name ) { $ this -> iset ( $ name , $ this -> getValue ( array ( 'select' => $ name , 'where' => array ( array ( static :: $ pk , $ this -> iget ( static :: $ pk ) ) ) ) ) ) ; }
Read and set a single object attribute from the database
240,310
public function update ( $ exclude = array ( ) , & $ db = FALSE ) { if ( $ db === FALSE ) { $ db = & $ this -> getDbMaster ( ) ; } $ old = FALSE ; if ( $ this -> changelog ( 'update' ) ) { $ old = static :: _Read ( $ this -> get ( static :: $ pk ) , $ db ) ; } $ exclude [ ] = static :: $ pk ; $ values = NULL ; foreach ...
Update an object in the database
240,311
public function hookTransactions ( Resource \ Db & $ parent , Resource \ Db & $ child = NULL ) { if ( ! $ child ) { $ child = & $ this -> getResource ( 'db' ) ; } if ( $ parent -> getTransactionCount ( ) > 0 && $ parent -> addTransactionHook ( $ child ) ) { $ child -> beginTransaction ( ) ; } }
Hook any database queries into another database transaction so that the queries are commited and rolled back at the same point
240,312
public function toXML ( $ attributes = FALSE ) { $ class = str_replace ( '\\' , '_' , str_replace ( 'sonic\\model\\' , '' , strtolower ( get_called_class ( ) ) ) ) ; $ doc = new \ DOMDocument ( '1.0' , 'UTF-8' ) ; $ node = $ doc -> createElement ( $ class ) ; $ doc -> appendChild ( $ node ) ; $ arr = $ this -> toArray ...
Return a DOM tree with object attributes
240,313
public function toJSON ( $ attributes = FALSE , $ addClass = FALSE ) { $ arr = $ this -> toArray ( $ attributes ) ; if ( $ addClass ) { $ arr [ 'class' ] = str_replace ( '\\' , '_' , str_replace ( 'sonic\\model\\' , '' , strtolower ( get_called_class ( ) ) ) ) ; } return json_encode ( $ arr ) ; }
Return a JSON encoded string with object attributes
240,314
public function fromArray ( $ attributes , $ removeClass = FALSE , $ validate = TRUE , $ required = array ( ) , $ valid = array ( ) ) { if ( $ removeClass ) { $ arr = array ( ) ; $ class = strtolower ( $ this -> getClass ( ) ) ; foreach ( array_keys ( static :: $ attributes ) as $ name ) { if ( isset ( $ attributes [ $...
Populate object attributes from an array
240,315
public function getChildren ( $ class , $ recursive = FALSE , $ index = FALSE , $ key = FALSE , $ params = array ( ) ) { $ children = self :: _getChildren ( $ class , $ this -> iget ( self :: $ pk ) , $ recursive , $ key , $ params ) ; if ( $ index ) { $ children = static :: _getChildrenIndex ( $ children ) ; } return ...
Return child objects matching class type
240,316
public function getValue ( $ params , $ fetchMode = \ PDO :: FETCH_ASSOC , & $ db = FALSE ) { if ( $ db === FALSE ) { $ db = & self :: _getDbSlave ( ) ; } $ params [ 'from' ] = '`' . static :: $ dbTable . '`' ; return $ db -> getValue ( $ params , $ fetchMode ) ; }
Return a single row
240,317
public function & getResource ( $ name ) { if ( ! isset ( $ this -> resources [ $ name ] ) ) { $ bln = FALSE ; return $ bln ; } return $ this -> resources [ $ name ] ; }
Return a class resource reference
240,318
public function setResource ( $ name , $ resource ) { $ obj = & Sonic :: getResource ( $ resource ) ; if ( ! $ obj ) { return FALSE ; } $ this -> setResourceObj ( $ name , $ obj ) ; return TRUE ; }
Set an internal resource from a framework resource
240,319
public function setResourceObj ( $ name , & $ resource ) { $ this -> resources [ $ name ] = & $ resource ; if ( isset ( $ this -> $ name ) ) { $ this -> $ name = & $ this -> resources [ $ name ] ; } }
Set a class resource from the resource object
240,320
public function removeResource ( $ name ) { if ( isset ( $ this -> resources [ $ name ] ) ) { unset ( $ this -> resources [ $ name ] ) ; if ( isset ( $ this -> $ name ) ) { unset ( $ this -> $ name ) ; } } }
Remove a class resource
240,321
public function removeResources ( ) { foreach ( array_keys ( $ this -> resources ) as $ name ) { if ( isset ( $ this -> $ name ) ) { unset ( $ this -> $ name ) ; } } unset ( $ this -> resources ) ; }
Remove all class resources
240,322
public static function _attributeProperties ( $ name , $ property = FALSE ) { if ( isset ( static :: $ attributes [ $ name ] ) ) { if ( $ property ) { if ( ! isset ( static :: $ attributes [ $ name ] [ $ property ] ) ) { return FALSE ; } return static :: $ attributes [ $ name ] [ $ property ] ; } return static :: $ att...
Return an attribute parameters array or FALSE if it doesnt exist Also pass option property array to return a single attribute property
240,323
public static function _read ( $ params , & $ db = FALSE ) { $ obj = new static ; if ( is_array ( $ params ) ) { $ params [ 'select' ] = '*' ; $ row = static :: _getValue ( $ params , \ PDO :: FETCH_ASSOC , $ db ) ; if ( ! $ row ) { return FALSE ; } foreach ( $ row as $ name => $ val ) { if ( $ obj -> attributeExists (...
Create a new object instance and read it from the database populating the object attributes
240,324
public static function _count ( $ params = array ( ) , & $ db = FALSE ) { if ( isset ( $ params [ 'orderby' ] ) ) { unset ( $ params [ 'orderby' ] ) ; } if ( isset ( $ params [ 'limit' ] ) ) { unset ( $ params [ 'limit' ] ) ; } $ params [ 'select' ] = 'COUNT(*)' ; return static :: _getValue ( $ params , \ PDO :: FETCH_...
Return the number of objects in the database matching the parameters
240,325
public static function _exists ( $ params , & $ db = FALSE ) { if ( ! is_array ( $ params ) ) { $ params = array ( 'where' => array ( array ( static :: $ pk , $ params ) ) ) ; } return self :: _count ( $ params , $ db ) > 0 ; }
Check to see whether the object matching the parameters exists
240,326
public static function _getObjects ( $ params = array ( ) , $ key = FALSE , & $ db = FALSE ) { if ( ! isset ( $ params [ 'select' ] ) ) { $ params [ 'select' ] = '*' ; } $ rows = static :: _getValues ( $ params , $ db ) ; if ( $ rows === FALSE ) { return FALSE ; } return self :: _arrayToObjects ( $ rows , $ key ) ; }
Create and return an array of objects for query parameters
240,327
public static function _queryToObjects ( $ query , $ key = FALSE ) { $ query -> execute ( ) ; return static :: _arrayToObjects ( $ query -> fetchAll ( \ PDO :: FETCH_ASSOC ) , $ key ) ; }
Execute a PDOStatement query and convert the results into objects
240,328
public static function _arrayToObjects ( $ arr , $ key = FALSE ) { $ objs = new Resource \ Model \ Collection ; if ( ! $ arr ) { return $ objs ; } foreach ( $ arr as $ row ) { $ obj = new static ; foreach ( $ row as $ name => $ val ) { if ( $ obj -> attributeExists ( $ name ) ) { $ obj -> iset ( $ name , $ val , FALSE ...
Convert an array into objects
240,329
public static function _genQuery ( $ params , & $ db = FALSE ) { if ( ! isset ( $ params [ 'select' ] ) ) { $ params [ 'select' ] = '*' ; } if ( ! isset ( $ params [ 'from' ] ) ) { $ params [ 'from' ] = '`' . static :: $ dbTable . '`' ; } if ( $ db === FALSE ) { $ db = & self :: _getDbSlave ( ) ; } if ( ! ( $ db instan...
Generate a query and return the PDOStatement object
240,330
public static function _genSQL ( $ params = array ( ) , & $ db = FALSE ) { if ( ! isset ( $ params [ 'select' ] ) ) { $ params [ 'select' ] = '*' ; } if ( ! isset ( $ params [ 'from' ] ) ) { $ params [ 'from' ] = '`' . static :: $ dbTable . '`' ; } if ( $ db === FALSE ) { $ db = & self :: _getDbSlave ( ) ; } if ( ! ( $...
Generate the SQL for a query on the model
240,331
public static function _toXML ( $ params = array ( ) , $ attributes = FALSE , & $ db = FALSE ) { $ class = str_replace ( '\\' , '_' , str_replace ( 'sonic\\model\\' , '' , strtolower ( get_called_class ( ) ) ) ) ; $ doc = new \ DOMDocument ( '1.0' , 'UTF-8' ) ; $ xml = $ doc -> createElement ( 'elements' ) ; $ doc -> a...
Return a DOM tree with objects for given query parameters
240,332
public static function _toJSON ( $ params = array ( ) , $ attributes = FALSE , $ addClass = FALSE , & $ db = FALSE ) { $ rows = static :: _toArray ( $ params , $ attributes , $ db ) ; if ( $ addClass ) { $ class = str_replace ( '\\' , '_' , str_replace ( 'sonic\\model\\' , '' , strtolower ( get_called_class ( ) ) ) ) ;...
Return a JSON encoded string with objects for given query parameters
240,333
public static function _toArray ( $ params = array ( ) , $ attributes = FALSE , & $ db = FALSE ) { if ( $ attributes === FALSE ) { $ attributes = array ( ) ; $ obj = new static ; foreach ( array_keys ( static :: $ attributes ) as $ name ) { if ( $ obj -> attributeGet ( $ name ) ) { $ attributes [ ] = $ name ; } } } if ...
Return an array with object attributes for given query parameters
240,334
public static function _getRelationPaths ( $ endClass , $ fork = array ( ) , $ paths = array ( ) , $ processed = array ( ) , $ depth = 0 ) { if ( $ endClass [ 0 ] == '\\' ) { $ endClass = substr ( $ endClass , 1 ) ; } if ( $ fork === FALSE ) { $ fork = array ( ) ; } $ class = get_called_class ( ) ; $ processed [ ] = st...
Return an array of available paths to a related class
240,335
public static function _getRelation ( $ obj , $ path , $ params = array ( ) ) { foreach ( $ path as $ class => $ name ) { $ class = get_class ( $ obj ) ; $ childClass = $ class :: $ attributes [ $ name ] [ 'relation' ] ; if ( $ obj -> iget ( $ name ) ) { $ params [ 'where' ] [ ] = array ( $ childClass :: $ pk , $ obj -...
Return a related object for a given object and path
240,336
public static function _getChildren ( $ class , $ id , $ recursive = FALSE , $ key = FALSE , $ params = array ( ) ) { if ( $ class [ 0 ] == '\\' ) { $ class = substr ( $ class , 1 ) ; } $ parent = get_called_class ( ) ; $ var = FALSE ; foreach ( $ class :: $ attributes as $ name => $ attribute ) { if ( isset ( $ attrib...
Return child objects with an attribute matching the current class and specified ID
240,337
public function getFromPivot ( \ Sonic \ Model $ target , \ Sonic \ Model $ pivot , $ key = FALSE , $ params = [ ] ) { $ sourceClass = get_called_class ( ) ; $ sourceRef = FALSE ; foreach ( $ pivot :: $ attributes as $ name => $ attribute ) { if ( isset ( $ attribute [ 'relation' ] ) && $ attribute [ 'relation' ] == $ ...
Return related objects from a many - to - many pivot table
240,338
public static function _getGrid ( $ params = array ( ) , $ relations = array ( ) , & $ db = FALSE ) { if ( ! $ params || ! isset ( $ params [ 'limit' ] ) ) { $ params [ 'limit' ] = array ( 0 , 50 ) ; } if ( $ relations ) { $ objs = static :: _getObjects ( $ params , $ db ) ; $ data = array ( ) ; foreach ( $ objs as $ o...
Return an array of items with total result count
240,339
public static function & _getResource ( $ name ) { if ( is_array ( $ name ) ) { return Sonic :: getResource ( $ name ) ; } else if ( isset ( static :: $ defaultResources [ $ name ] ) ) { return Sonic :: getResource ( static :: $ defaultResources [ $ name ] ) ; } else { return Sonic :: getSelectedResource ( $ name ) ; }...
Return a class resource This will either be the default as defined for the class or the global framework resource
240,340
public static function & _getRandomDbResource ( $ group ) { $ obj = FALSE ; while ( Sonic :: countResourceGroup ( $ group ) > 0 ) { $ name = Sonic :: selectRandomResource ( $ group ) ; $ obj = & Sonic :: getResource ( array ( $ group , $ name ) ) ; if ( $ obj instanceof \ PDO ) { if ( $ obj instanceof Resource \ Db ) {...
Return random database resource object
240,341
private function changelog ( $ type ) { if ( isset ( static :: $ changelogIgnore ) ) { if ( static :: $ changelogIgnore === TRUE || is_array ( static :: $ changelogIgnore ) && in_array ( $ type , static :: $ changelogIgnore ) ) { return FALSE ; } } if ( ! ( $ this -> getResource ( 'changelog' ) instanceof Resource \ Ch...
Whether to write to the changelog
240,342
public function css ( $ path , $ plugin = false , $ appendTime = true , array $ attributes = [ ] ) { $ href = $ this -> getUrl ( $ path , $ plugin , $ appendTime ) ; return '<link rel="stylesheet" type="text/css" href="' . $ href . '"' . $ this -> _renderAttributes ( $ attributes ) . '>' ; }
Output a link stylesheet tag for a specific css file and optionally append a last modified timestamp to clear the browser cache .
240,343
public function js ( $ path , $ plugin = false , $ appendTime = true , array $ attributes = [ ] ) { $ src = $ this -> getUrl ( $ path , $ plugin , $ appendTime ) ; return '<script type="text/javascript" src="' . $ src . '"' . $ this -> _renderAttributes ( $ attributes ) . '></script>' ; }
Output a script tag for a specific js file and optionally append a last modified timestamp to clear the browser cache .
240,344
public function getUrl ( $ path , $ plugin , $ appendTime = true ) { $ pathParts = explode ( '/' , $ path ) ; $ isAssetPath = ( $ pathParts [ 0 ] === 'ASSETS' ) ; if ( $ isAssetPath ) { $ absPath = $ this -> _getBaseAssetPath ( $ plugin ) . join ( '/' , array_slice ( $ pathParts , 1 ) ) ; } else { $ absPath = $ this ->...
Get the asset url for a specific file .
240,345
protected function _getBasePath ( $ plugin = false ) { if ( $ plugin !== false ) { return $ this -> _getPluginPath ( $ plugin ) . 'webroot' . DS ; } return WWW_ROOT ; }
Get the base path to the app webroot or a plugin webroot .
240,346
protected function _renderAttributes ( array $ attributes = [ ] ) { $ attributeStrings = [ ] ; foreach ( $ attributes as $ attribute => $ value ) { $ attributeStrings [ ] = $ attribute . '="' . htmlentities ( $ value ) . '"' ; } if ( empty ( $ attributeStrings ) ) { return '' ; } return ' ' . join ( ' ' , $ attributeSt...
Render attribute key value pairs as html attributes .
240,347
public function renderWidget ( ) { echo Html :: beginTag ( 'div' , [ 'class' => 'nestable-box' ] ) ; foreach ( $ this -> items as $ item ) { $ this -> renderGroup ( $ item ) ; } echo Html :: endTag ( 'div' ) ; if ( $ this -> hasModel ( ) ) { echo Html :: activeHiddenInput ( $ this -> model , $ this -> attribute ) ; } e...
Initializes and renders the widget
240,348
public function http ( ) { $ this -> writeln ( 'Starting swoole http server...' ) ; $ server = new HttpServer ( $ this -> swooleConfig [ 'http' ] [ 'host' ] ?? self :: DEFAULT_SWOOLE_HOST , $ this -> swooleConfig [ 'http' ] [ 'port' ] ?? self :: DEFAULT_SWOOLE_PORT ) ; $ server -> on ( 'Request' , function ( $ request ...
Swoole Http Server
240,349
public function tcp ( ) { $ this -> writeln ( 'Starting swoole tcp server...' ) ; $ server = new TcpServer ( $ this -> swooleConfig [ 'tcp' ] [ 'host' ] ?? self :: DEFAULT_SWOOLE_HOST , $ this -> swooleConfig [ 'tcp' ] [ 'port' ] ?? self :: DEFAULT_SWOOLE_PORT ) ; $ server -> set ( [ 'open_eof_split' => true , 'package...
Swoole Tcp Server
240,350
public function udp ( ) { $ this -> writeln ( 'Starting swoole udp server...' ) ; $ udpServer = new TcpServer ( $ this -> swooleConfig [ 'upd' ] [ 'host' ] ?? self :: DEFAULT_SWOOLE_HOST , $ this -> swooleConfig [ 'upd' ] [ 'port' ] ?? self :: DEFAULT_SWOOLE_PORT , SWOOLE_PROCESS , SWOOLE_SOCK_UDP ) ; $ udpServer -> se...
Swoole UDP Server
240,351
public function websocket ( ) { $ this -> writeln ( 'Starting swoole websocket server...' ) ; $ ws = new WebsocketServer ( $ this -> swooleConfig [ 'ws' ] [ 'host' ] ?? self :: DEFAULT_SWOOLE_HOST , $ this -> swooleConfig [ 'ws' ] [ 'port' ] ?? self :: DEFAULT_SWOOLE_PORT ) ; $ ws -> on ( 'open' , function ( $ ws , $ r...
Swoole Websocket Server
240,352
public function mqtt ( ) { $ this -> writeln ( 'Starting swoole mqtt server...' ) ; $ serv = new TcpServer ( $ this -> swooleConfig [ 'tcp' ] [ 'host' ] ?? self :: DEFAULT_SWOOLE_HOST , $ this -> swooleConfig [ 'tcp' ] [ 'port' ] ?? self :: DEFAULT_SWOOLE_PORT , SWOOLE_BASE ) ; $ serv -> set ( array ( 'open_mqtt_protoc...
Swoole Mqtt Server
240,353
public function udpClient ( ) { $ this -> writeln ( 'Starting demo swoole udp client...' ) ; $ client = new TcpClient ( SWOOLE_SOCK_UDP , SWOOLE_SOCK_ASYNC ) ; $ client -> on ( 'connect' , function ( $ cli ) { $ cli -> send ( JsonHelper :: encode ( [ 'handler' => SwooleTcpJob :: class ] ) . self :: EOF ) ; } ) ; $ clie...
Swoole UDP Client Demo
240,354
public function websocketClient ( ) { $ this -> writeln ( 'Starting demo websocket client...' ) ; $ client = new Client ( 'ws://' . ( $ this -> swooleConfig [ 'ws' ] [ 'host' ] ?? self :: DEFAULT_SWOOLE_HOST ) . ':' . ( $ this -> swooleConfig [ 'ws' ] [ 'port' ] ?? self :: DEFAULT_SWOOLE_PORT ) ) ; $ client -> send ( J...
Websocket Client Demo
240,355
final protected function map ( ) { $ result = df_map_0 ( [ ] , $ met = $ this -> isRequirementMet ( ) ? null : $ this -> requirement ( ) ) ; if ( $ met ) { try { $ result += $ this -> fetch ( ) ; } catch ( \ Exception $ e ) { $ result = $ this -> exception ( $ e ) ; } } return $ result ; }
2017 - 07 - 02
240,356
public function getControllerOptions ( ) { if ( empty ( $ this -> controllerOptions ) ) { $ routePluginManager = $ this -> getServiceLocator ( ) ; if ( empty ( $ routePluginManager ) ) { throw new Exception \ RuntimeException ( 'ServiceLocator not set' ) ; } $ sl = $ routePluginManager -> getServiceLocator ( ) ; if ( e...
Fetches and returns the associated ListControllerOptions for this route
240,357
protected function extractValue ( ModelStubInterface $ model , $ name , $ value , $ extractName = true ) { $ modelHydrator = $ model -> getHydrator ( ) ; if ( ! $ modelHydrator || ! method_exists ( $ modelHydrator , 'extractValue' ) ) { throw new Exception \ RuntimeException ( 'Model hydrator must be set and must have ...
Extract a value in order to be used within datagateway context
240,358
protected function extractName ( ModelStubInterface $ model , $ name ) { if ( $ model -> getObjectPrototype ( ) instanceof HydratorAwareInterface ) { $ objectHydrator = $ model -> getObjectPrototype ( ) -> getHydrator ( ) ; if ( ! $ objectHydrator || ! method_exists ( $ objectHydrator , 'hydrateName' ) ) { throw new Ex...
Extract a name in order to be used within datagateway context
240,359
protected function _getSpaceAlignmentInArray ( $ lineIndex , $ testable ) { if ( ! $ lineIndex ) { return ; } $ tokens = $ testable -> tokens ( ) ; $ lines = $ testable -> lines ( ) ; $ lineCache = $ testable -> lineCache ( ) ; $ prevLine = $ lines [ $ lineIndex - 1 ] ; $ previousTokens = $ lineCache [ $ testable -> fi...
Return the minimal space required for a multilined expression in an array definition .
240,360
protected function _getIndent ( $ line ) { $ count = $ space = $ tab = 0 ; $ end = strlen ( $ line ) ; while ( ( $ count < $ end ) && ( $ line [ $ count ] === "\t" ) ) { $ tab ++ ; $ count ++ ; } while ( ( $ count < $ end ) && ( $ line [ $ count ] === ' ' ) ) { $ space ++ ; $ count ++ ; } return array ( 'space' => $ sp...
Will determine how many tabs are at the beginning of a line .
240,361
public function configure ( $ prefix , $ resourceName , array $ options ) { $ this -> prefix = $ prefix ; $ this -> resourceName = $ resourceName ; $ this -> options = $ this -> getOptionsResolver ( ) -> resolve ( $ options ) ; return $ this ; }
Configures the pool builder .
240,362
private function createEntityClassParameter ( ) { $ id = $ this -> getServiceId ( 'class' ) ; if ( ! $ this -> container -> hasParameter ( $ id ) ) { $ this -> container -> setParameter ( $ id , $ this -> options [ 'entity' ] ) ; } $ this -> configureInheritanceMapping ( $ this -> prefix . '.' . $ this -> resourceName ...
Creates the entity class parameter .
240,363
private function createConfigurationDefinition ( ) { $ id = $ this -> getServiceId ( 'configuration' ) ; if ( ! $ this -> container -> has ( $ id ) ) { $ definition = new Definition ( self :: CONFIGURATION ) ; $ definition -> setFactory ( [ new Reference ( 'ekyna_admin.pool_factory' ) , 'createConfiguration' ] ) -> set...
Creates the Configuration service definition .
240,364
private function buildTemplateList ( $ templatesConfig ) { $ templateNamespace = self :: DEFAULT_TEMPLATES ; if ( is_string ( $ templatesConfig ) ) { $ templateNamespace = $ templatesConfig ; } $ templatesList = [ ] ; foreach ( self :: $ templates as $ name => $ extensions ) { foreach ( $ extensions as $ extension ) { ...
Builds the templates list .
240,365
private function createManagerDefinition ( ) { $ id = $ this -> getServiceId ( 'manager' ) ; if ( ! $ this -> container -> has ( $ id ) ) { $ this -> container -> setAlias ( $ id , new Alias ( $ this -> getManagerServiceId ( ) ) ) ; } }
Creates the manager definition .
240,366
private function createRepositoryDefinition ( ) { $ id = $ this -> getServiceId ( 'repository' ) ; if ( ! $ this -> container -> has ( $ id ) ) { $ definition = new Definition ( $ class = $ this -> getServiceClass ( 'repository' ) ) ; $ definition -> setArguments ( [ new Reference ( $ this -> getServiceId ( 'manager' )...
Creates the Repository service definition .
240,367
private function createOperatorDefinition ( ) { $ id = $ this -> getServiceId ( 'operator' ) ; if ( ! $ this -> container -> has ( $ id ) ) { $ definition = new Definition ( $ this -> getServiceClass ( 'operator' ) ) ; $ definition -> setArguments ( [ new Reference ( $ this -> getManagerServiceId ( ) ) , new Reference ...
Creates the operator service definition .
240,368
private function createControllerDefinition ( ) { $ id = $ this -> getServiceId ( 'controller' ) ; if ( ! $ this -> container -> has ( $ id ) ) { $ definition = new Definition ( $ this -> getServiceClass ( 'controller' ) ) ; $ definition -> addMethodCall ( 'setConfiguration' , [ new Reference ( $ this -> getServiceId (...
Creates the Controller service definition .
240,369
private function configureTranslations ( ) { if ( null !== array_key_exists ( 'translation' , $ this -> options ) && is_array ( $ this -> options [ 'translation' ] ) ) { $ translatable = $ this -> options [ 'entity' ] ; $ translation = $ this -> options [ 'translation' ] [ 'entity' ] ; $ id = sprintf ( '%s.%s_translati...
Configure the translation
240,370
private function configureInheritanceMapping ( $ id , $ entity , $ repository ) { $ entities = [ $ id => [ 'class' => $ entity , 'repository' => $ repository , ] , ] ; if ( $ this -> container -> hasParameter ( 'ekyna_core.entities' ) ) { $ entities = array_merge ( $ this -> container -> getParameter ( 'ekyna_core.enti...
Configures mapping inheritance .
240,371
private function getServiceClass ( $ name ) { $ serviceId = $ this -> getServiceId ( $ name ) ; $ parameterId = $ serviceId . '.class' ; if ( $ this -> container -> hasParameter ( $ parameterId ) ) { $ class = $ this -> container -> getParameter ( $ parameterId ) ; } elseif ( array_key_exists ( $ name , $ this -> optio...
Returns the service class for the given name .
240,372
public function getDescription ( ) { return isset ( $ this -> _data [ self :: PROFILE ] [ self :: DESCRIPTION ] ) ? $ this -> _data [ self :: PROFILE ] [ self :: DESCRIPTION ] : null ; }
Retrieves the user s description .
240,373
public function getName ( ) { return isset ( $ this -> _data [ self :: PROFILE ] [ self :: NAME ] ) ? $ this -> _data [ self :: PROFILE ] [ self :: NAME ] : null ; }
Retrieves the user s name .
240,374
public function getLocation ( ) { return isset ( $ this -> _data [ self :: PROFILE ] [ self :: LOCATION ] ) ? $ this -> _data [ self :: PROFILE ] [ self :: LOCATION ] : null ; }
Retrieves the user s location .
240,375
public function getTwitter ( ) { return isset ( $ this -> _data [ self :: PROFILE ] [ self :: TWITTER_USERNAME ] ) ? $ this -> _data [ self :: PROFILE ] [ self :: TWITTER_USERNAME ] : null ; }
Retrieves the user s twitter username .
240,376
public function getWebsite ( ) { return isset ( $ this -> _data [ self :: PROFILE ] [ self :: WEBSITE ] ) ? $ this -> _data [ self :: PROFILE ] [ self :: WEBSITE ] : null ; }
Retrievs the user s website .
240,377
public function getServices ( ) { return isset ( $ this -> _data [ self :: PROFILE ] [ self :: SERVICES ] ) ? $ this -> _data [ self :: PROFILE ] [ self :: SERVICES ] : null ; }
Retrieves the user s services .
240,378
public function getQwerly ( ) { return isset ( $ this -> _data [ self :: PROFILE ] [ self :: QWERLY ] ) ? $ this -> _data [ self :: PROFILE ] [ self :: QWERLY ] : null ; }
Retrieves the user s qwerly username .
240,379
public function getFacebook ( ) { return isset ( $ this -> _data [ self :: PROFILE ] [ self :: FACEBOOK_ID ] ) ? $ this -> _data [ self :: PROFILE ] [ self :: FACEBOOK_ID ] : null ; }
Retrieves the user s facebook id .
240,380
function alphaId ( $ in , $ to_num = false , $ pad_up = false , $ pass_key = null ) { $ out = '' ; $ index = 'abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ' ; $ base = strlen ( $ index ) ; if ( $ pass_key !== null ) { for ( $ n = 0 ; $ n < strlen ( $ index ) ; $ n ++ ) { $ i [ ] = substr ( $ index , $ ...
Translates a number to a short alhanumeric version
240,381
protected function _buildRequest ( ) { $ this -> _request = $ this -> _factory -> getNewCancelBuildRequest ( $ this -> _api , $ this -> _order ) -> build ( ) ; return $ this ; }
Build order cancel payload .
240,382
protected function _sendRequest ( ) { $ this -> _response = $ this -> _factory -> getNewCancelSendRequest ( $ this -> _api , $ this -> _request ) -> send ( ) ; return $ this ; }
Send order cancel payload .
240,383
protected function _processResponse ( ) { $ this -> _factory -> getNewCancelProcessResponse ( $ this -> _response , $ this -> _order ) -> process ( ) ; return $ this ; }
Process order cancel response .
240,384
public static function create ( $ code , $ value = 0 ) { $ cd = strtoupper ( $ code ) ; list ( $ symbol , $ precision , $ name ) = self :: getDefinition ( $ cd ) ; $ crcy = new Currency ( $ value , $ cd , $ symbol , $ precision , $ name ) ; $ crcy -> setLocale ( self :: getLocale ( ) ) ; return $ crcy ; }
Create a currency
240,385
protected static function getDefinition ( $ code ) { $ currencies = self :: getDefinitions ( ) ; $ nodes = $ currencies -> xpath ( "//currency[@code='{$code}']" ) ; if ( empty ( $ nodes ) ) { throw new \ InvalidArgumentException ( "Unknown currency: {$code}" ) ; } $ cNode = $ nodes [ 0 ] ; $ def = array ( self :: creat...
Get a currency definition
240,386
protected static function getDefinitions ( ) { if ( empty ( self :: $ definitions ) ) { self :: $ definitions = \ simplexml_load_file ( __DIR__ . '/currencies.xml' ) ; } return self :: $ definitions ; }
Load currency definitions
240,387
protected static function createSymbol ( \ SimpleXMLElement $ sNode , $ code ) { switch ( ( string ) $ sNode [ 'type' ] ) { case 'UCS' : $ symbol = ( string ) $ sNode [ 'UTF-8' ] ; break ; case null : default : $ symbol = $ code ; break ; } return $ symbol ; }
Create currency symbol from the symbol node
240,388
protected static function createName ( \ SimpleXMLElement $ currency ) { $ locale = self :: getLocale ( ) ; $ nodes = $ currency -> xpath ( "name[@lang='{$locale}']" ) ; if ( count ( $ nodes ) > 0 ) { return ( string ) $ nodes [ 0 ] ; } $ lang = \ locale_get_primary_language ( $ locale ( ) ) ; $ nodes = $ currency -> x...
Find closest matching name for a currency based on currently set locale . Default to en entry if none more suitable found
240,389
protected function getTotal ( $ directory , array $ options = array ( ) ) { $ options [ 'count' ] = true ; return ( int ) $ this -> scanner -> scan ( $ directory , $ options ) ; }
Returns a total number of scanned files
240,390
protected function getRelativePath ( $ path = null ) { if ( ! isset ( $ path ) ) { $ path = $ this -> scanner -> getInitialPath ( true ) ; } return gplcart_path_normalize ( gplcart_path_relative ( $ path ) ) ; }
Returns a relative file path or initial directory
240,391
protected function move ( $ src , $ dest , & $ errors = 0 , & $ success = 0 ) { $ this -> copy ( $ src , $ dest , $ errors , $ success ) ; if ( empty ( $ errors ) ) { gplcart_file_delete_recursive ( $ src , $ errors ) ; } return empty ( $ errors ) ; }
Moves a file to a new destination
240,392
protected function isInitialPath ( $ file ) { $ current_path = gplcart_path_normalize ( $ file -> getRealPath ( ) ) ; $ initial_path = gplcart_path_normalize ( $ this -> scanner -> getInitialPath ( true ) ) ; return $ current_path === $ initial_path ; }
Whether the current file is the initial file manager path
240,393
public function setLocation ( Location $ location ) { foreach ( $ this -> handlers as $ handler ) { if ( $ handler instanceof LocationAwareHandlerInterface ) { $ handler -> setLocation ( $ location ) ; } } }
Passes location to location aware handlers
240,394
public function setContent ( Content $ content ) { foreach ( $ this -> handlers as $ handler ) { if ( $ handler instanceof ContentAwareHandlerInterface ) { $ handler -> setContent ( $ content ) ; } } }
Passes content to content aware handlers
240,395
public function httpAction ( ) { $ status = self :: STATUS_SUCCESS ; $ responses = array ( ) ; $ exception = null ; $ data = null ; $ debug = $ this -> getRouteParam ( 'debug' , false ) ; try { $ service = $ this -> fetchService ( ) ; $ operation = $ service ? $ this -> fetchOperation ( ) : false ; if ( ! $ service ) {...
Performs service operation matched by HTTP router
240,396
public function consoleAction ( ) { $ request = $ this -> getRequest ( ) ; $ service = $ this -> fetchService ( ) ; $ operation = $ this -> fetchOperation ( ) ; $ query = $ this -> fetchConsoleQuery ( ) ; if ( ! $ request instanceof ConsoleRequest ) { throw new \ RuntimeException ( 'You can only use this action from a ...
Performs service operation routed by console router
240,397
protected function prepareHttpResponse ( $ data , $ status , $ exception = null ) { $ error = $ this -> getRequest ( ) -> getHeader ( self :: HEADER_ERRORS , self :: HEADER_ERRORS_DEFAULT ) ; $ forceHtmlContentType = $ this -> getRequest ( ) -> getHeader ( self :: HEADER_FORCE_CONTENT_HTML , false ) ; if ( $ error inst...
Prepares HTTP response
240,398
protected function prepareConsoleResponse ( $ data , \ Exception $ exception = null , $ verbose = false , $ silent = false ) { $ response = new ConsoleResponse ( ) ; try { if ( is_array ( $ data ) || is_object ( $ data ) ) { $ json = JsonEncoder :: encode ( $ data , true ) ; $ data = Json :: prettyPrint ( $ json ) . "\...
Prepares console response
240,399
protected function fetchService ( ) { $ service = $ this -> getRouteParam ( 'service' ) ; $ service = $ this -> parseCanonicalName ( $ service , true ) ; if ( preg_match ( $ this -> servicePattern , $ service ) ) { return $ service ; } else { return false ; } }
Parse service name from request