idx
int64 0
60.3k
| question
stringlengths 64
4.24k
| target
stringlengths 5
618
|
|---|---|---|
6,800
|
public function get ( string $ name , $ default = null ) { $ path = explode ( '.' , $ name ) ; $ current = $ this -> data ; foreach ( $ path as $ field ) { if ( isset ( $ current ) && isset ( $ current [ $ field ] ) ) { $ current = $ current [ $ field ] ; } elseif ( is_array ( $ current ) && isset ( $ current [ $ field ] ) ) { $ current = $ current [ $ field ] ; } else { return $ default ; } } return $ current ; }
|
Get value by using dot notation for nested arrays .
|
6,801
|
public static function registerCustomRouteClass ( string $ routeKey , string $ routeClass ) { self :: checkRegisterAvailability ( ) ; if ( ! class_exists ( $ routeClass ) ) throw new AppLogicException ( 'Class ' . $ routeClass . ' does not exist' ) ; self :: $ customRouteClasses [ $ routeKey ] = $ routeClass ; }
|
Can t set custom actions . Only parsable from URL
|
6,802
|
public function getHttpClient ( $ path ) { $ this -> httpClient = new Http \ Client ( ) ; $ this -> httpClient -> setAdapter ( $ this -> getHttpAdapter ( ) ) ; $ this -> httpClient -> setUri ( $ this -> options [ 'base_url' ] . $ path ) ; return $ this -> httpClient ; }
|
Get Http Client
|
6,803
|
public function getHttpAdapter ( ) { if ( null === $ this -> httpAdapter ) { $ this -> httpAdapter = new Http \ Client \ Adapter \ Curl ( ) ; $ this -> httpAdapter -> setOptions ( array ( 'curloptions' => array ( CURLOPT_SSL_VERIFYPEER => false , ) , ) ) ; } return $ this -> httpAdapter ; }
|
Get Http Adapter
|
6,804
|
static function getInstance ( eZContentObjectAttribute $ objectAttribute ) { $ datatypeString = $ objectAttribute -> attribute ( 'data_type_string' ) ; $ dataTypeHandlers = self :: $ ogIni -> variable ( 'OpenGraph' , 'DataTypeHandlers' ) ; if ( array_key_exists ( $ datatypeString , $ dataTypeHandlers ) ) { if ( class_exists ( $ dataTypeHandlers [ $ datatypeString ] ) ) { return new $ dataTypeHandlers [ $ datatypeString ] ( $ objectAttribute ) ; } } return new ngOpenGraphBase ( $ objectAttribute ) ; }
|
Gets the instance of Open Graph attribute handler for the attribute
|
6,805
|
final public function commitChanges ( ) { if ( null !== $ this -> changes ) { $ this -> lastCommittedEventSequenceNumber = $ this -> changes -> lastSequenceNumber ( ) ; $ this -> changes -> commit ( ) ; } }
|
Clears all recorded events .
|
6,806
|
final protected function applyChange ( Serializable $ payload ) { $ this -> apply ( $ payload ) ; $ this -> changes ( ) -> addEventFromPayload ( $ payload ) ; }
|
Mutate the state of the aggregate by applying a domain event . Keep track of the change until it has been successfully committed .
|
6,807
|
final private function replayChange ( Event $ event ) { $ this -> apply ( $ event -> payload ( ) ) ; $ this -> lastCommittedEventSequenceNumber = $ event -> sequenceNumber ( ) ; }
|
Mutate the state of the aggregate by applying the domain event contained into the message . Synchronize the aggregate version with the one provided by the message .
|
6,808
|
final private function apply ( Serializable $ payload ) { $ method = $ this -> applyMethod ( $ payload ) ; $ this -> $ method ( $ payload ) ; }
|
Mutate the state of the aggregate by applying a domain event .
|
6,809
|
protected function applyMethod ( Serializable $ payload ) { $ className = get_class ( $ payload ) ; return 'apply' . substr ( $ className , strrpos ( $ className , '\\' ) + 1 ) ; }
|
Returns method to call for applying a given domain event to the aggregate . This can be overridden to suit your custom naming convention .
|
6,810
|
final private function changes ( ) { if ( null === $ this -> changes ) { $ lastCommittedEventSequenceNumber = $ this -> lastCommittedEventSequenceNumber ( ) ; $ this -> changes = new DefaultEventContainer ( $ this -> identifier ( ) , $ lastCommittedEventSequenceNumber ) ; } return $ this -> changes ; }
|
Return the event container containing the uncommitted changes . If there are no pending changes to be committed a new event container will be initialized .
|
6,811
|
final public static function loadFromHistory ( EventStream $ eventStream ) { $ aggregate = new static ( ) ; while ( $ eventStream -> hasNext ( ) ) { $ aggregate -> replayChange ( $ eventStream -> next ( ) ) ; } return $ aggregate ; }
|
Roll - out all events to reconstitute the state of the aggregate .
|
6,812
|
public function setRelationType ( $ type , $ direction = 'bidirectional' , $ whoIsOwningSide = 'source' ) { $ this -> setDirection ( $ direction ) ; $ this -> setType ( $ type ) ; if ( isset ( $ whoIsOwningSide ) ) $ this -> setOwningSide ( $ whoIsOwningSide ) ; return $ this ; }
|
Setzt alle Eigenschaften der Relation gleichzeitig
|
6,813
|
public function setJoinColumnNullable ( $ bool ) { $ this -> nullable = $ bool ; $ this -> getJoinColumn ( ) -> setNullable ( $ bool ) ; return $ this ; }
|
Achtung dies erzeugt die JoinColumn und sollte nur benutzt werdne wenn die Relation schon korrekt gesetzt ist
|
6,814
|
private function packagePath ( string $ relativePath ) : string { $ packagePath = rtrim ( str_replace ( '/' , DIRECTORY_SEPARATOR , $ this -> packagePath ) , DIRECTORY_SEPARATOR ) ; $ relativePath = ltrim ( str_replace ( '/' , DIRECTORY_SEPARATOR , $ relativePath ) , DIRECTORY_SEPARATOR ) ; return realpath ( $ packagePath . DIRECTORY_SEPARATOR . $ relativePath ) ; }
|
give relative path from package root and return absolute path
|
6,815
|
public function getList ( ) { $ key = $ this -> name . '_' . md5 ( $ this -> value ) ; if ( isset ( self :: $ listobj [ $ key ] ) ) { return self :: $ listobj [ $ key ] ; } if ( $ this -> value ) { self :: $ listobj [ $ key ] = json_decode ( $ this -> value ) ; } else { self :: $ listobj [ $ key ] = false ; } return self :: $ listobj [ $ key ] ; }
|
Get the list
|
6,816
|
public function getHeading ( ) { $ list = $ this -> getList ( ) ; if ( isset ( $ list -> heading ) && $ list -> heading ) { return Convert :: html2raw ( $ list -> heading ) ; } return null ; }
|
Get list heading
|
6,817
|
public function getItems ( ) { $ list = $ this -> getList ( ) ; if ( isset ( $ list -> items ) && ! empty ( $ list -> items ) ) { $ arrayList = new ArrayList ( ) ; foreach ( $ list -> items as $ id => $ item ) { $ item -> ID = $ id ; $ arrayList -> push ( new ArrayData ( $ item ) ) ; } return $ arrayList ; } return false ; }
|
Get list items
|
6,818
|
static function encode ( $ data , $ getterPrefixForObjectMethods = 'get' , $ ignoreNulls = false ) { $ type = gettype ( $ data ) ; $ isObject = false ; switch ( $ type ) { case 'string' : return '"' . self :: fixString ( $ data ) . '"' ; case 'number' : ; case 'integer' : ; case 'float' : ; case 'double' : return $ data ; case 'boolean' : return ( $ data ) ? 'true' : 'false' ; case 'NULL' : return 'null' ; case 'object' : { $ className = get_class ( $ data ) ; if ( array_key_exists ( $ className , self :: $ conversions ) && is_callable ( self :: $ conversions [ $ className ] ) ) { $ function = self :: $ conversions [ $ className ] ; $ convertedValue = call_user_func ( $ function , $ data ) ; return self :: encode ( $ convertedValue ) ; } $ data = RTTI :: getAttributes ( $ data , RTTI :: anyVisibility ( ) , $ getterPrefixForObjectMethods ) ; $ isObject = true ; } case 'array' : { $ output = array ( ) ; foreach ( $ data as $ key => $ value ) { $ encodedValue = self :: encode ( $ value , $ getterPrefixForObjectMethods ) ; if ( $ ignoreNulls && 'null' === $ encodedValue ) { continue ; } if ( is_numeric ( $ key ) ) { $ output [ ] = $ encodedValue ; } else { $ encodedKey = self :: encode ( $ key , $ getterPrefixForObjectMethods ) ; $ output [ ] = $ encodedKey . ': ' . $ encodedValue ; } } return $ isObject ? '{ ' . implode ( ', ' , $ output ) . ' }' : '[ ' . implode ( ', ' , $ output ) . ' ]' ; } default : return '' ; } }
|
Encodes a variable into JSON format .
|
6,819
|
static function decode ( $ json , $ convertObjectsToArrays = false , $ recursionDepth = 512 , $ options = 0 ) { return json_decode ( $ json , $ convertObjectsToArrays , $ recursionDepth , $ options ) ; }
|
Decodes a JSON content into an object or an array .
|
6,820
|
public function refreshAccessToken ( OAuthToken $ token ) { $ params = [ 'grant_type' => 'refresh_token' ] ; $ params = array_merge ( $ token -> getParams ( ) , $ params ) ; $ request = $ this -> createRequest ( ) -> setMethod ( 'POST' ) -> setUrl ( $ this -> refreshTokenUrl ) -> setData ( $ params ) ; $ this -> applyClientCredentialsToRequest ( $ request ) ; $ response = $ this -> sendRequest ( $ request ) ; $ token = $ this -> createToken ( [ 'params' => $ response ] ) ; $ this -> setAccessToken ( $ token ) ; return $ token ; }
|
Gets new auth token to replace expired one .
|
6,821
|
protected function _initialize ( ) { $ config = $ this -> _config -> get ( 'joomla' ) ; if ( is_null ( $ config ) || ! is_array ( $ config ) ) { $ config = array ( ) ; } $ defaults = array ( 'name' => 'root' , 'username' => 'root' , 'groups' => array ( 8 ) , 'email' => 'root@localhost.home' ) ; $ this -> _credentials = array_merge ( $ defaults , $ config ) ; $ this -> _bootstrap ( ) ; $ this -> _loadFramework ( ) ; }
|
Initializes extension installer .
|
6,822
|
protected function _getElementFromManifest ( $ manifest , $ manifestPath ) { $ element = '' ; $ type = ( string ) $ manifest -> attributes ( ) -> type ; switch ( $ type ) { case 'component' : $ name = strtolower ( ( string ) $ manifest -> name ) ; $ element = preg_replace ( '/[^A-Z0-9_\.-]/i' , '' , $ name ) ; if ( substr ( $ element , 0 , 4 ) != 'com_' ) { $ element = 'com_' . $ element ; } break ; case 'module' : case 'plugin' : if ( count ( $ manifest -> files -> children ( ) ) ) { foreach ( $ manifest -> files -> children ( ) as $ file ) { if ( ( string ) $ file -> attributes ( ) -> $ type ) { $ element = ( string ) $ file -> attributes ( ) -> $ type ; break ; } } } break ; case 'file' : case 'library' : $ element = substr ( $ manifestPath , 0 , - strlen ( '.xml' ) ) ; break ; case 'package' : $ element = preg_replace ( '/[^A-Z0-9_\.-]/i' , '' , $ manifest -> packagename ) ; if ( substr ( $ element , 0 , 4 ) != 'pkg_' ) { $ element = 'pkg_' . $ element ; } break ; case 'language' : $ element = $ manifest -> get ( 'tag' ) ; break ; case 'template' : $ name = preg_replace ( '/[^A-Z0-9_ \.-]/i' , '' , $ manifest -> name ) ; $ element = strtolower ( str_replace ( ' ' , '_' , $ name ) ) ; break ; default : break ; } return $ element ; }
|
Load the element name from the installation manifest .
|
6,823
|
public function setName ( $ name ) { if ( mb_strpos ( $ name , '\\' ) !== FALSE ) { $ this -> setNamespace ( Code :: getNamespace ( $ name ) ) ; $ this -> name = Code :: getClassName ( $ name ) ; } else { $ this -> name = $ name ; $ this -> namespace = NULL ; } return $ this ; }
|
Setzt den Namen der Klasse
|
6,824
|
public function removeInterface ( GClass $ class ) { if ( array_key_exists ( $ n = $ class -> getFQN ( ) , $ this -> interfaces ) ) { unset ( $ this -> interfaces [ $ n ] ) ; } return $ this ; }
|
Entfernt das Interface aus der Klasse
|
6,825
|
protected static function get_config ( ) { $ config_file = \ alsvanzelf \ fem \ ROOT_DIR . 'config/github.ini' ; if ( file_exists ( $ config_file ) == false ) { $ exception = bootstrap :: get_library ( 'exception' ) ; throw new $ exception ( 'no github application config found' ) ; } return parse_ini_file ( $ config_file ) ; }
|
collects a config containing the github app codes from a ini file
|
6,826
|
public static function get_by_info ( $ info , $ update_oauth_token = true ) { $ mysql = bootstrap :: get_library ( 'mysql' ) ; $ sql = "SELECT * FROM `login_github` WHERE `oauth_token` = '%s';" ; $ login = $ mysql :: select ( 'row' , $ sql , $ info [ 'oauth_token' ] ) ; if ( ! empty ( $ login ) ) { return new static ( $ login [ 'id' ] ) ; } $ sql = "SELECT * FROM `login_github` WHERE `github_username` = '%s';" ; $ login = $ mysql :: select ( 'row' , $ sql , $ info [ 'github_username' ] ) ; if ( empty ( $ login ) ) { return false ; } $ object = new static ( $ login [ 'id' ] ) ; if ( $ update_oauth_token && $ info [ 'oauth_token' ] != $ login [ 'oauth_token' ] ) { $ object -> update_oauth_token ( $ info [ 'oauth_token' ] ) ; } return $ object ; }
|
checks whether the login match one on file and returns the found login
|
6,827
|
public static function get_by_user_id ( $ user_id ) { $ mysql = bootstrap :: get_library ( 'mysql' ) ; $ sql = "SELECT * FROM `login_github` WHERE `user_id` = %d;" ; $ login = $ mysql :: select ( 'row' , $ sql , $ user_id ) ; if ( empty ( $ login ) ) { return false ; } return new static ( $ login [ 'id' ] ) ; }
|
checks whether the given user id match a login on file and returns the found login
|
6,828
|
public static function get_by_github_username ( $ github_username ) { $ mysql = bootstrap :: get_library ( 'mysql' ) ; $ sql = "SELECT * FROM `login_github` WHERE `github_username` = '%s';" ; $ login = $ mysql :: select ( 'row' , $ sql , $ github_username ) ; if ( empty ( $ login ) ) { return false ; } return new static ( $ login [ 'id' ] ) ; }
|
checks whether the given github username match one on file and returns the found login
|
6,829
|
public static function get_by_oauth_token ( $ oauth_token ) { $ mysql = bootstrap :: get_library ( 'mysql' ) ; $ sql = "SELECT * FROM `login_github` WHERE `oauth_token` = '%s';" ; $ login = $ mysql :: select ( 'row' , $ sql , $ oauth_token ) ; if ( empty ( $ login ) ) { return false ; } return new static ( $ login [ 'id' ] ) ; }
|
checks whether the given oauth token match one on file and returns the found login
|
6,830
|
public static function signup ( $ user_id , $ info ) { if ( empty ( $ info [ 'github_username' ] ) || empty ( $ info [ 'oauth_token' ] ) || empty ( $ info [ 'scope' ] ) ) { $ exception = bootstrap :: get_library ( 'exception' ) ; throw new $ exception ( 'all info from ::is_valid() is needed for signup' ) ; } $ mysql = bootstrap :: get_library ( 'mysql' ) ; $ sql = "INSERT INTO `login_github` SET `user_id` = %d, `github_username` = '%s', `oauth_token` = '%s', `scope` = '%s' ;" ; $ binds = [ $ user_id , $ info [ 'github_username' ] , $ info [ 'oauth_token' ] , $ info [ 'scope' ] ] ; $ mysql :: query ( $ sql , $ binds ) ; return new static ( $ mysql :: $ insert_id ) ; }
|
adds a new login connection between a local user and a github account
|
6,831
|
public function update_oauth_token ( $ new_oauth_token ) { $ mysql = bootstrap :: get_library ( 'mysql' ) ; $ sql = "UPDATE `login_github` SET `oauth_token` = '%s' WHERE `id` = %d;" ; $ binds = [ $ new_oauth_token , $ this -> id ] ; $ mysql :: query ( $ sql , $ binds ) ; }
|
updates the oauth token for the login
|
6,832
|
public static function request_authorization ( $ scope = null , $ callback_url = null ) { $ config = static :: get_config ( ) ; if ( ! empty ( $ callback_url ) && strpos ( $ callback_url , $ config [ 'callback_url' ] ) !== 0 ) { $ exception = bootstrap :: get_library ( 'exception' ) ; throw new $ exception ( 'custom callback url needs to start with defined callback url' ) ; } if ( empty ( $ callback_url ) ) { $ callback_url = $ config [ 'callback_url' ] ; } $ text = bootstrap :: get_library ( 'text' ) ; $ session = bootstrap :: get_library ( 'session' ) ; $ request = bootstrap :: get_library ( 'request' ) ; $ state = $ text :: generate_token ( $ length = 40 ) ; $ session :: start ( session :: TYPE_TEMPORARY ) ; $ _SESSION [ 'fem/login_github/state' ] = $ state ; $ _SESSION [ 'fem/login_github/scope' ] = $ scope ; $ url = 'https://github.com/login/oauth/authorize' ; $ arguments = [ 'client_id' => $ config [ 'client_id' ] , 'scope' => $ scope , 'state' => $ state , ] ; $ request :: redirect ( $ url . '?' . http_build_query ( $ arguments ) ) ; }
|
send a user to github to authorize our application
|
6,833
|
public static function is_valid ( $ callback_data , $ extended = true ) { $ exception = bootstrap :: get_library ( 'exception' ) ; if ( empty ( $ callback_data [ 'state' ] ) ) { throw new $ exception ( 'state expected in oauth callback' ) ; } $ session = bootstrap :: get_library ( 'session' ) ; $ session :: start ( $ session :: TYPE_TEMPORARY ) ; if ( $ callback_data [ 'state' ] != $ _SESSION [ 'fem/login_github/state' ] ) { throw new $ exception ( 'state is different, someone tries to fake the callback?' ) ; } if ( empty ( $ callback_data [ 'code' ] ) ) { return false ; } if ( $ extended ) { return static :: is_valid_extended ( $ callback_data ) ; } return true ; }
|
checks whether an oauth callback contains a valid state and code
|
6,834
|
public static function exchange_for_oauth_token ( $ code ) { $ config = static :: get_config ( ) ; $ url = 'https://github.com/login/oauth/access_token' ; $ options = [ 'body' => [ 'client_id' => $ config [ 'client_id' ] , 'client_secret' => $ config [ 'client_secret' ] , 'code' => $ code , ] , 'headers' => [ 'Accept' => 'application/json' , ] , ] ; $ http = new \ GuzzleHttp \ Client ( ) ; $ response = $ http -> post ( $ url , $ options ) -> json ( ) ; if ( empty ( $ response [ 'access_token' ] ) ) { $ exception = bootstrap :: get_library ( 'exception' ) ; throw new $ exception ( 'can not get oauth token for temporary code' ) ; } return [ 'oauth_token' => $ response [ 'access_token' ] , 'scope' => $ response [ 'scope' ] , ] ; }
|
exchange the temporary code for a lasting oauth token
|
6,835
|
public static function verify_scope ( $ received_scope , $ requested_scope = 'user:email' ) { if ( strpos ( $ received_scope , $ requested_scope ) !== false ) { return true ; } if ( strpos ( $ requested_scope , ':' ) ) { $ parent_requested_scope = substr ( $ requested_scope , 0 , strpos ( $ requested_scope , ':' ) ) ; if ( strpos ( $ received_scope , $ parent_requested_scope ) !== false ) { return true ; } } return false ; }
|
checks whether the received scope meets the requested scope
|
6,836
|
public static function get_user_info ( $ oauth_token ) { $ url = 'https://api.github.com/user' ; $ options = [ 'headers' => [ 'Accept' => 'application/json' , 'Authorization' => 'token ' . $ oauth_token , ] , ] ; $ http = new \ GuzzleHttp \ Client ( ) ; return $ http -> get ( $ url , $ options ) -> json ( ) ; }
|
gets a users github account details for a given oauth token
|
6,837
|
public static function verify_user ( $ oauth_token , $ github_username ) { $ known_login = static :: get_by_oauth_token ( $ oauth_token ) ; if ( empty ( $ known_login ) ) { return true ; } if ( $ known_login -> github_username != $ github_username ) { $ exception = bootstrap :: get_library ( 'exception' ) ; throw new $ exception ( 'oauth token switched user' ) ; } return true ; }
|
checks whether the username belongs to the user identified by the oauth token
|
6,838
|
public static function doCount ( Criteria $ criteria , $ distinct = false , PropelPDO $ con = null ) { $ criteria = clone $ criteria ; $ criteria -> setPrimaryTableName ( UserPeer :: TABLE_NAME ) ; if ( $ distinct && ! in_array ( Criteria :: DISTINCT , $ criteria -> getSelectModifiers ( ) ) ) { $ criteria -> setDistinct ( ) ; } if ( ! $ criteria -> hasSelectClause ( ) ) { UserPeer :: addSelectColumns ( $ criteria ) ; } $ criteria -> clearOrderByColumns ( ) ; $ criteria -> setDbName ( UserPeer :: DATABASE_NAME ) ; if ( $ con === null ) { $ con = Propel :: getConnection ( UserPeer :: DATABASE_NAME , Propel :: CONNECTION_READ ) ; } $ stmt = BasePeer :: doCount ( $ criteria , $ con ) ; if ( $ row = $ stmt -> fetch ( PDO :: FETCH_NUM ) ) { $ count = ( int ) $ row [ 0 ] ; } else { $ count = 0 ; } $ stmt -> closeCursor ( ) ; return $ count ; }
|
Returns the number of rows matching criteria .
|
6,839
|
public static function doDeleteAll ( PropelPDO $ con = null ) { if ( $ con === null ) { $ con = Propel :: getConnection ( UserPeer :: DATABASE_NAME , Propel :: CONNECTION_WRITE ) ; } $ affectedRows = 0 ; try { $ con -> beginTransaction ( ) ; $ affectedRows += UserPeer :: doOnDeleteCascade ( new Criteria ( UserPeer :: DATABASE_NAME ) , $ con ) ; $ affectedRows += BasePeer :: doDeleteAll ( UserPeer :: TABLE_NAME , $ con , UserPeer :: DATABASE_NAME ) ; UserPeer :: clearInstancePool ( ) ; UserPeer :: clearRelatedInstancePool ( ) ; $ con -> commit ( ) ; return $ affectedRows ; } catch ( Exception $ e ) { $ con -> rollBack ( ) ; throw $ e ; } }
|
Deletes all rows from the user table .
|
6,840
|
public function hasAccess ( $ name ) { $ permissions = $ this -> getPermissions ( $ name ) ; $ roles = $ this -> getRoles ( $ name ) ; if ( $ permissions === null && $ roles === null ) { return null ; } return $ this -> keeper -> hasPermissions ( $ permissions ) === true && $ this -> keeper -> hasRoles ( $ roles ) === true ; }
|
Check if current user has access to named route
|
6,841
|
public function getPermissions ( $ name ) { $ route = $ this -> router -> getRoutes ( ) -> getByName ( $ name ) ; if ( $ route === null ) { return null ; } $ permissions = [ ] ; foreach ( $ route -> middleware ( ) as $ middleware ) { if ( strpos ( $ middleware , 'permission:' ) === 0 ) { list ( , $ permission ) = explode ( ':' , $ middleware , 2 ) ; $ permissions [ ] = $ permission ; } } $ action = $ route -> getAction ( ) ; if ( array_key_exists ( 'permission' , $ action ) ) { $ permissions [ ] = $ action [ 'permission' ] ; } if ( array_key_exists ( 'permissions' , $ action ) ) { $ permissions = array_merge ( $ permissions , $ action [ 'permissions' ] ) ; } return array_unique ( $ permissions ) ; }
|
Get permissions for named route
|
6,842
|
public function getRoles ( $ name ) { $ route = $ this -> router -> getRoutes ( ) -> getByName ( $ name ) ; if ( $ route === null ) { return null ; } $ roles = [ ] ; $ action = $ route -> getAction ( ) ; if ( array_key_exists ( 'role' , $ action ) ) { $ roles [ ] = $ action [ 'role' ] ; } if ( array_key_exists ( 'roles' , $ action ) ) { $ roles = array_merge ( $ roles , $ action [ 'roles' ] ) ; } return array_unique ( $ roles ) ; }
|
Get roles for named route
|
6,843
|
public function store ( $ object ) { if ( ! is_object ( $ object ) ) { throw new InvalidArgumentException ( 1 , 'object' ) ; } $ objects = array ( ) ; $ id = $ this -> doStore ( $ this -> freezer -> freeze ( $ object , $ objects ) ) ; if ( $ id !== null ) { $ object -> { $ this -> freezer -> getIdProperty ( ) } = $ id ; } return $ object -> { $ this -> freezer -> getIdProperty ( ) } ; }
|
Freezes an object and stores it in the object storage .
|
6,844
|
public function logMemory ( $ object = null , $ name = 'PHP' , $ literal = false ) { $ memory = memory_get_usage ( ) ; $ dataType = '' ; if ( ! is_null ( $ object ) && ! $ literal ) { $ memory = strlen ( serialize ( $ object ) ) ; $ dataType = gettype ( $ object ) ; } else if ( is_numeric ( $ object ) && $ literal ) { $ memory = floatval ( $ object ) ; } array_push ( $ this -> store , array ( 'name' => $ name , 'data' => $ memory , 'data_type' => $ dataType , 'type' => 'memory' ) ) ; }
|
Logs memory usage of a variable If no parameter is passed in logs current memory usage
|
6,845
|
public function logError ( Exception $ exception , $ message = '' ) { if ( empty ( $ message ) ) { $ message = $ exception -> getMessage ( ) ; } array_push ( $ this -> store , array ( 'data' => $ message , 'file' => $ exception -> getFile ( ) , 'line' => $ exception -> getLine ( ) , 'type' => 'error' ) ) ; }
|
Logs exception with optional message override
|
6,846
|
public function logSpeed ( $ name = 'Point in Time' , $ literalTime = null ) { $ time = microtime ( true ) ; if ( ! is_null ( $ literalTime ) && is_float ( $ literalTime ) ) { $ time = $ literalTime ; } array_push ( $ this -> store , array ( 'data' => $ time , 'name' => $ name , 'type' => 'speed' ) ) ; }
|
Logs current time with optional message
|
6,847
|
public function setMatchTypes ( $ matchTypes ) { if ( is_array ( $ matchTypes ) ) { $ this -> matchTypes = $ matchTypes ; } else { foreach ( ( array ) $ matchTypes as $ key => $ matchType ) { $ this -> matchTypes [ $ key ] = $ matchType ; } } }
|
Match types are used to replace given search with replace
|
6,848
|
public function mount ( $ baseroute , $ callable , $ extra = [ ] ) { $ Route = clone $ this -> Route ; $ this -> Route -> addExtra ( $ extra ) ; $ curBaseroute = $ this -> baseUri ; $ this -> baseUri .= $ baseroute ; $ callable ( $ this ) ; $ this -> Route = $ Route ; $ this -> baseUri = $ curBaseroute ; }
|
Mount multiple routes via callabck
|
6,849
|
public function findRequestMethod ( ) { $ method = $ _SERVER [ "REQUEST_METHOD" ] ; if ( $ method === "POST" ) { if ( isset ( $ _SERVER [ "X-HTTP-Method-Override" ] ) ) { $ method = $ _SERVER [ "X-HTTP-Method-Override" ] ; } } return $ this -> method = $ method ; }
|
Automatically find the request method
|
6,850
|
public function findUri ( ) { $ uri = parse_url ( $ _SERVER [ "REQUEST_URI" ] , PHP_URL_PATH ) ; return ( $ this -> lowerCase ) ? strtolower ( $ uri ) : $ uri ; }
|
Automatically find the current uri using baseuri
|
6,851
|
public function addRoute ( $ method , $ route , $ action , $ extra = [ ] ) { $ name = ( isset ( $ extra [ "name" ] ) ) ? $ extra [ "name" ] : $ route ; if ( isset ( $ this -> rawRoutes [ $ name ] ) ) { $ Route = $ this -> rawRoutes [ $ name ] ; } else { $ Route = clone $ this -> Route ; $ Route -> route = $ this -> baseUri . $ route ; $ Route -> name = $ name ; } $ Route -> addExtra ( $ extra ) ; $ methods = [ ] ; if ( "ANY" === $ method ) { $ methods [ "GET" ] = $ action ; $ methods [ "POST" ] = & $ methods [ "GET" ] ; $ methods [ "PUT" ] = & $ methods [ "GET" ] ; $ Route -> methods = $ methods ; $ Route -> action = $ action ; $ this -> rawRoutes [ $ name ] = $ Route ; } else { $ arrayedMethod = ( array ) $ method ; $ count = count ( $ arrayedMethod ) ; for ( $ i = 0 ; $ i < $ count ; $ i ++ ) { if ( ! isset ( $ this -> allowedMethods [ $ arrayedMethod [ $ i ] ] ) ) { throw new InvalidMethodException ( "Method: " . $ arrayedMethod [ $ i ] . " is not valid" ) ; } $ method = $ arrayedMethod [ $ i ] ; $ Route -> action = $ action ; $ Route -> method = $ method ; $ Route -> name = $ name ; $ this -> rawRoutes [ $ name ] = $ Route ; } } return $ Route ; }
|
Add new route to list of available routes
|
6,852
|
public function getMatchType ( $ type , $ default = null ) { if ( isset ( $ this -> matchTypes [ $ type ] ) ) { return $ this -> matchTypes [ $ type ] ; } else if ( $ default !== null ) { return $ default ; } else { throw new MatchTypeNotFoundExeption ( "Unknow match type" ) ; } }
|
Return regex if type is defined otherwise returns default value .
|
6,853
|
public function normalize ( $ route ) { if ( mb_substr ( $ route , - 1 , 1 ) == "/" ) { $ route = substr ( $ route , 0 , - 1 ) ; } $ result = explode ( "/" , $ route ) ; $ result [ 0 ] = $ this -> baseUri ; $ ret = [ ] ; foreach ( $ result as $ v ) { if ( ! $ v ) { continue ; } if ( ( $ v [ 0 ] ) === "?{" ) { $ ret [ ] = [ "name" => explode ( "?}" , mb_substr ( $ v , 1 ) ) [ 0 ] , "use" => "?" ] ; } else if ( ( $ v [ 0 ] ) === "{" ) { $ ret [ ] = [ "name" => explode ( "}" , mb_substr ( $ v , 1 ) ) [ 0 ] , "use" => "*" ] ; } else { $ ret [ ] = [ "name" => $ v , "use" => $ v ] ; } } return $ ret ; }
|
Normalize route structure and extract dynamic and optional parts
|
6,854
|
protected function parseRoutes ( $ routes ) { $ tree = [ ] ; foreach ( $ routes as $ Route ) { $ node = & $ tree ; $ routeSegments = $ this -> normalize ( $ Route -> route ) ; foreach ( $ routeSegments as $ segment ) { if ( ! isset ( $ node [ $ segment [ "use" ] ] ) ) { $ node [ $ segment [ "use" ] ] = [ "name" => $ segment [ "name" ] , "routeName" => $ Route -> name ] ; } $ node = & $ node [ $ segment [ "use" ] ] ; } $ Route -> segments = $ routeSegments ; $ node [ "exec" ] [ "method" ] [ $ Route -> method ] = $ Route ; } return $ tree ; }
|
Build tree structure from all routes .
|
6,855
|
public function split ( int $ max ) : iterable { $ pos = 0 ; $ total = count ( $ this -> values ) ; while ( $ pos < $ total ) { $ clone = clone $ this ; $ clone -> values = array_slice ( $ this -> values , $ pos , $ max ) ; $ pos += $ max ; yield $ clone ; } }
|
Split into multiple INSERT statements .
|
6,856
|
function save ( ) { if ( ! $ this -> blnChanged ) { return ; } $ flags = JSON_PRETTY_PRINT ; $ strContent = json_encode ( $ this -> options , $ flags ) ; file_put_contents ( __CODEGEN_OPTION_FILE__ , $ strContent ) ; $ this -> blnChanged = false ; }
|
Save the current configuration into the options file .
|
6,857
|
public function setOption ( $ strTableName , $ strFieldName , $ strOptionName , $ mixValue ) { $ this -> options [ $ strTableName ] [ $ strFieldName ] [ $ strOptionName ] = $ mixValue ; $ this -> blnChanged = true ; }
|
Set an option for a widget associated with the given table and field .
|
6,858
|
public function setOptions ( $ strClassName , $ strFieldName , $ mixValue ) { if ( empty ( $ mixValue ) ) { unset ( $ this -> options [ $ strClassName ] [ $ strFieldName ] ) ; } else { $ this -> options [ $ strClassName ] [ $ strFieldName ] = $ mixValue ; } $ this -> blnChanged = true ; }
|
Bulk option setting .
|
6,859
|
public function unsetOption ( $ strClassName , $ strFieldName , $ strOptionName ) { unset ( $ this -> options [ $ strClassName ] [ $ strFieldName ] [ $ strOptionName ] ) ; $ this -> blnChanged = true ; }
|
Remove the option
|
6,860
|
public function getOption ( $ strClassName , $ strFieldName , $ strOptionName ) { if ( isset ( $ this -> options [ $ strClassName ] [ $ strFieldName ] [ $ strOptionName ] ) ) { return $ this -> options [ $ strClassName ] [ $ strFieldName ] [ $ strOptionName ] ; } else { return null ; } }
|
Lookup an option .
|
6,861
|
public function getOptions ( $ strClassName , $ strFieldName ) { if ( isset ( $ this -> options [ $ strClassName ] [ $ strFieldName ] ) ) { return $ this -> options [ $ strClassName ] [ $ strFieldName ] ; } else { return array ( ) ; } }
|
Return all the options associated with the given table and field .
|
6,862
|
public function serialize ( ) { $ raw = [ ] ; foreach ( $ this -> listProperties ( ) as $ propName ) { $ raw [ $ propName ] = $ this -> { $ propName } ; } $ raw [ '_try_index' ] = $ this -> _try_index + 1 ; return serialize ( $ raw ) ; }
|
This default implementation stores all public and protected properties .
|
6,863
|
public function getFolderChildrens ( array $ input ) { $ organizationId = $ this -> AuthenticationManager -> getCurrentUserOrganization ( 'id' ) ; $ file = $ this -> File -> byId ( $ input [ 'id' ] ) ; $ fileTree = array ( 'text' => $ file -> name , 'state' => array ( 'opened' => true ) , 'icon' => $ file -> icon , 'children' => array ( ) ) ; $ this -> File -> byParentId ( $ input [ 'id' ] , $ organizationId ) -> each ( function ( $ file ) use ( & $ fileTree ) { if ( $ file -> type == 'C' ) { array_push ( $ fileTree [ 'children' ] , array ( 'text' => $ file -> name , 'icon' => $ file -> icon ) ) ; } else { array_push ( $ fileTree [ 'children' ] , array ( 'text' => $ file -> name , 'icon' => $ file -> icon ) ) ; } } ) ; return json_encode ( array ( 'fileTree' => $ fileTree ) ) ; }
|
Get Files children
|
6,864
|
public function getElementFiles ( array $ systemReferences , $ formatAsHtml = true , $ databaseConnectionName = null , $ organizationId = null ) { $ files = array ( ) ; if ( empty ( $ organizationId ) ) { $ organizationId = $ this -> AuthenticationManager -> getCurrentUserOrganizationId ( ) ; } foreach ( $ systemReferences as $ systemReference ) { $ this -> File -> bySystemReferenceTypeBySystemReferenceIdAndByOrganization ( $ this -> journalConfigurations [ $ systemReference [ 'appId' ] ] [ 'journalizedType' ] [ 0 ] , $ systemReference [ 'systemReferenceId' ] , $ organizationId , $ databaseConnectionName ) -> each ( function ( $ File ) use ( & $ files ) { array_push ( $ files , array ( 'id' => $ File -> id , 'name' => $ File -> name , 'size' => 0 , 'url' => $ File -> url , 'icon' => str_replace ( 'font-size: 2em;' , '' , $ File -> icon_html ) ) ) ; } ) ; } return json_encode ( $ files ) ; }
|
Get element files by system parent type and by system parent id
|
6,865
|
public function getLocalFilePath ( $ filename , $ route , & $ isTempFile , $ includeStoragePath = false ) { $ isTempFile = false ; if ( $ this -> Config -> get ( 'filesystems.default' ) == 'gcs' ) { $ isTempFile = true ; $ this -> Storage -> disk ( 'local' ) -> put ( '//temp/' . $ filename , $ this -> Storage -> read ( $ route ) ) ; $ route = 'temp/' . $ filename ; } if ( $ includeStoragePath ) { return storage_path ( 'app' ) . '/' . $ route ; } return $ route ; }
|
Get local file path
|
6,866
|
public function servePrivateFile ( $ key ) { $ File = $ this -> File -> byKeyAndPublic ( $ key , false ) -> first ( ) ; if ( ! is_null ( $ File ) ) { return $ this -> serveFile ( $ File -> system_type , $ File -> system_route , $ File -> name ) ; } return $ this -> Redirector -> to ( $ this -> AppManager -> getErrorPageUrl ( ) ) -> withError ( $ this -> Lang -> get ( 'decima-file::file-management.fileNotFound' ) ) ; }
|
Serve private file
|
6,867
|
public function connect ( ) { if ( $ this -> isConnected ( ) ) { return true ; } if ( ! $ this -> isEnabled ( ) ) { throw new MissingDriverException ( sprintf ( '%s driver extension is not enabled' , $ this -> getDriver ( ) ) ) ; } $ this -> _connections [ $ this -> getContext ( ) ] = new PDO ( $ this -> getDsn ( ) , $ this -> getUser ( ) , $ this -> getPassword ( ) , $ this -> getConfig ( 'flags' ) + [ PDO :: ATTR_PERSISTENT => $ this -> isPersistent ( ) , PDO :: ATTR_ERRMODE => PDO :: ERRMODE_EXCEPTION ] ) ; return true ; }
|
Connect to the database using PDO .
|
6,868
|
public function resolveBind ( $ field , $ value , array $ schema = [ ] ) { $ type = null ; if ( $ field instanceof Func ) { return [ $ value , $ this -> resolveType ( $ value ) ] ; } if ( $ value instanceof RawExpr ) { $ value = $ value -> getValue ( ) ; } if ( $ value === null ) { $ type = PDO :: PARAM_NULL ; } else if ( isset ( $ schema [ $ field ] [ 'type' ] ) ) { $ dataType = $ this -> getType ( $ schema [ $ field ] [ 'type' ] ) ; $ value = $ dataType -> to ( $ value ) ; $ type = $ dataType -> getBindingType ( ) ; } if ( ! $ type ) { $ type = $ this -> resolveType ( $ value ) ; } return [ $ value , $ type ] ; }
|
Resolve the bind value and the PDO binding type .
|
6,869
|
public function resolveParams ( Query $ query ) { $ params = [ ] ; $ schema = $ query -> getRepository ( ) -> getSchema ( ) -> getColumns ( ) ; foreach ( $ query -> getGroupedBindings ( ) as $ groupedBinds ) { foreach ( $ groupedBinds as $ binds ) { $ params [ ] = $ this -> resolveBind ( $ binds [ 'field' ] , $ binds [ 'value' ] , $ schema ) ; } } foreach ( $ query -> getCompounds ( ) as $ compound ) { $ params = array_merge ( $ params , $ this -> resolveParams ( $ compound ) ) ; } return $ params ; }
|
Resolve the list of values that will be required for PDO statement binding .
|
6,870
|
public function resolveType ( $ value ) { if ( $ value === null ) { $ type = PDO :: PARAM_NULL ; } else if ( is_resource ( $ value ) ) { $ type = PDO :: PARAM_LOB ; } else if ( is_numeric ( $ value ) ) { if ( is_float ( $ value ) || is_double ( $ value ) ) { $ type = PDO :: PARAM_STR ; } else { $ type = PDO :: PARAM_INT ; } } else if ( is_bool ( $ value ) ) { $ type = PDO :: PARAM_BOOL ; } else { $ type = PDO :: PARAM_STR ; } return $ type ; }
|
Resolve the value type for PDO parameter binding and quoting .
|
6,871
|
public static function parse ( $ cmd ) { if ( empty ( $ cmd ) ) { return false ; } $ params = array ( ) ; $ in_string = false ; $ len = strlen ( $ cmd ) ; $ crr_prm = "" ; $ command_str = $ cmd ; $ cmd = array ( ) ; for ( $ i = 0 ; $ len > $ i ; $ i ++ ) { $ char = $ command_str [ $ i ] ; switch ( $ char ) { case ' ' : if ( ! $ in_string ) { $ cmd [ ] = $ crr_prm ; $ crr_prm = '' ; } else { $ crr_prm .= $ char ; } break ; case '"' : if ( $ i > 0 && $ command_str [ $ c - 1 ] != '\\' ) { $ in_string = ! $ in_string ; } break ; default : $ crr_prm .= $ char ; break ; } } $ cmd [ ] = $ crr_prm ; $ controller = array_shift ( $ cmd ) ; $ action = null ; if ( strpos ( $ controller , '::' ) !== false ) { $ controller = explode ( '::' , $ controller ) ; $ action = $ controller [ 1 ] ; $ controller = $ controller [ 0 ] ; } $ skip = false ; foreach ( $ cmd as $ key => $ value ) { if ( $ skip ) { $ skip = false ; continue ; } if ( substr ( $ value , 0 , 1 ) == '-' ) { if ( array_key_exists ( $ key + 1 , $ cmd ) ) { $ next_value = $ cmd [ $ key + 1 ] ; if ( substr ( $ next_value , 0 , 1 ) == '-' ) { $ params [ substr ( $ value , 1 ) ] = true ; } else { $ params [ substr ( $ value , 1 ) ] = $ next_value ; $ skip = true ; } } else { $ params [ substr ( $ value , 1 ) ] = true ; } } else { $ params [ ] = $ value ; } } return static :: run ( trim ( $ controller ) , trim ( $ action ) , $ params ) ; }
|
Parse an command and execute console style
|
6,872
|
public static function run ( $ controller , $ action = null , $ params = array ( ) ) { CCFile :: enable_infos ( ) ; if ( empty ( $ action ) ) { $ action = 'default' ; } $ path = CCPath :: get ( $ controller , CCDIR_CONSOLE , EXT ) ; if ( ! file_exists ( $ path ) ) { if ( ! CCPath :: contains_namespace ( $ controller ) ) { $ path = CCPath :: get ( CCCORE_NAMESPACE . '::' . $ controller , CCDIR_CONSOLE , EXT ) ; } } if ( ! file_exists ( $ path ) ) { CCCli :: line ( "Could not find controller {$controller}." , 'red' ) ; return false ; } $ class = 'CCConsole\\' . $ controller ; \ CCFinder :: bind ( $ class , $ path ) ; $ class = new $ class ( $ action , $ params ) ; if ( method_exists ( $ class , 'wake' ) ) { call_user_func ( array ( $ class , 'wake' ) , $ params ) ; } call_user_func ( array ( $ class , '_execute' ) , $ action , $ params ) ; if ( method_exists ( $ class , 'sleep' ) ) { call_user_func ( array ( $ class , 'sleep' ) , $ params ) ; } }
|
Run a console script
|
6,873
|
public function _execute ( $ action , $ params = array ( ) ) { if ( method_exists ( $ this , 'action_' . $ action ) ) { call_user_func ( array ( $ this , 'action_' . $ action ) , $ params ) ; } else { CCCli :: line ( "There is no action {$action}." , 'red' ) ; } }
|
execute the controller
|
6,874
|
public function action_help ( $ params ) { if ( method_exists ( $ this , 'help' ) ) { CCCli :: line ( $ this -> help_formatter ( $ this -> help ( ) ) ) ; return ; } CCCli :: line ( 'This console controller does not implement an help function or action.' , 'cyan' ) ; }
|
default help action
|
6,875
|
public static function create ( $ name = null , $ file = null , $ url = null ) { return new static ( $ name , $ file , $ url ) ; }
|
Create a new InstallScript Element
|
6,876
|
protected function _dataTooltip ( array $ options , $ tooltip ) { if ( Arr :: key ( 'title' , $ options ) ) { $ options [ 'data-tooltip' ] = $ options [ 'title' ] ; } if ( is_string ( $ tooltip ) ) { $ options [ 'data-tooltip' ] = $ tooltip ; } return $ options ; }
|
Setup tooltip data - tooltip attr .
|
6,877
|
protected function _prepareBtn ( Helper $ helper , array $ options , $ button ) { $ options = $ helper -> addClass ( $ options , 'waves-effect waves-light btn' ) ; if ( ! empty ( $ button ) ) { $ options = $ helper -> addClass ( $ options , Str :: trim ( ( string ) $ button ) ) ; } return $ options ; }
|
Prepare form buttons .
|
6,878
|
protected function _prepareTooltip ( Helper $ helper , array $ options , $ tooltip ) { $ _options = [ 'data-position' => 'top' ] ; if ( Arr :: key ( 'tooltipPos' , $ options ) ) { $ _options [ 'data-position' ] = ( string ) $ options [ 'tooltipPos' ] ; unset ( $ options [ 'tooltipPos' ] ) ; } $ options = $ this -> _tooltipTitle ( $ options , $ tooltip ) ; $ options = $ this -> _dataTooltip ( $ options , $ tooltip ) ; $ options = $ helper -> addClass ( $ options , 'hasTooltip' ) ; return Hash :: merge ( $ _options , $ options ) ; }
|
Prepare tooltip attrs .
|
6,879
|
protected function _tooltipTitle ( array $ options , $ tooltip ) { if ( $ tooltip === true && ! Arr :: key ( 'title' , $ options ) ) { $ options [ 'title' ] = strip_tags ( $ options [ 'label' ] ) ; } if ( is_string ( $ tooltip ) ) { $ options [ 'title' ] = $ tooltip ; } return $ options ; }
|
Setup tooltip title .
|
6,880
|
public function action_build ( $ params ) { $ test_directories = array ( ) ; if ( is_dir ( APPPATH . CCDIR_TEST ) ) { $ this -> line ( 'found tests in your application.' ) ; $ test_directories [ 'App' ] = APPPATH . CCDIR_TEST ; } if ( $ params [ '-include-core' ] ) { $ test_directories [ 'Core' ] = COREPATH . '../' . CCDIR_TEST ; } foreach ( \ CCFinder :: $ bundles as $ bundle => $ path ) { if ( is_dir ( $ path . CCDIR_TEST ) ) { $ this -> info ( 'found tests in the ' . $ bundle . ' bundle.' ) ; $ test_directories [ $ bundle ] = $ path . CCDIR_TEST ; } } foreach ( $ test_directories as $ key => $ dir ) { $ test_directories [ $ key ] = './' . str_replace ( CCROOT , '' , $ dir ) ; } $ xml = new \ DOMDocument ( "1.0" , 'UTF-8' ) ; $ root = $ xml -> createElement ( "phpunit" ) ; $ testsuites = $ xml -> createElement ( "testsuites" ) ; foreach ( $ test_directories as $ key => $ dir ) { $ testsuite = $ xml -> createElement ( "testsuite" ) ; $ testsuite -> setAttribute ( 'name' , $ key . ' tests' ) ; $ directory = $ xml -> createElement ( "directory" , $ dir ) ; $ directory -> setAttribute ( 'suffix' , EXT ) ; $ testsuite -> appendChild ( $ directory ) ; $ testsuites -> appendChild ( $ testsuite ) ; } $ root -> appendChild ( $ testsuites ) ; $ root = $ xml -> appendChild ( $ root ) ; $ root -> setAttribute ( 'colors' , 'true' ) ; $ root -> setAttribute ( 'bootstrap' , 'boot/phpunit.php' ) ; $ xml -> formatOutput = true ; \ CCFile :: write ( CCROOT . 'phpunit.xml' , $ xml -> saveXML ( ) ) ; }
|
Builds the phpunit . xml file
|
6,881
|
public function setDataWithKeys ( Array $ keys , $ value ) { $ data = & $ this -> data ; if ( $ keys === array ( ) ) { if ( ! is_array ( $ value ) ) { throw new DataInputException ( 'Wenn $keys leer ist, darf value nur ein array sein!' ) ; } return $ data = $ value ; } $ lastKey = array_pop ( $ keys ) ; foreach ( $ keys as $ key ) { if ( ! array_key_exists ( $ key , $ data ) ) { $ data [ $ key ] = array ( ) ; } $ data = & $ data [ $ key ] ; } $ data [ $ lastKey ] = $ value ; return $ data ; }
|
Setzt einen Wert mit einem Pfad
|
6,882
|
public function set ( $ keys , $ value ) { if ( is_string ( $ keys ) ) $ keys = explode ( '.' , $ keys ) ; if ( is_integer ( $ keys ) ) $ keys = array ( $ keys ) ; return $ this -> setDataWithKeys ( $ keys , $ value ) ; }
|
Setzt einen Wert in den Daten
|
6,883
|
public function strategy ( $ strategy = null ) { if ( is_null ( $ strategy ) ) { $ strategy = $ this -> defaultStrategy ? : OrderStrategy :: class ; } if ( ! class_exists ( $ strategy ) ) { $ strategy = __NAMESPACE__ . '\strategies\\' . ucfirst ( $ strategy ) ; } if ( ! class_exists ( $ strategy ) ) { throw new InvalidArgumentException ( "Unsupported strategy \"{$strategy}\"" ) ; } if ( empty ( $ this -> strategies [ $ strategy ] ) || ! ( $ this -> strategies [ $ strategy ] instanceof StrategyInterface ) ) { $ this -> strategies [ $ strategy ] = new $ strategy ( $ this ) ; } return $ this -> strategies [ $ strategy ] ; }
|
Get a strategy instance .
|
6,884
|
public function get ( $ id , $ throwException = true ) { if ( isset ( $ this -> _gateways [ $ id ] ) ) { return $ this -> _gateways [ $ id ] ; } if ( isset ( $ this -> _definitions [ $ id ] ) ) { $ definition = $ this -> _definitions [ $ id ] ; if ( is_object ( $ definition ) && ! $ definition instanceof Closure ) { return $ this -> _gateways [ $ id ] = $ definition ; } return $ this -> _gateways [ $ id ] = Yii :: createObject ( $ definition ) ; } elseif ( $ throwException ) { throw new InvalidConfigException ( "Unknown gateway ID: $id" ) ; } return null ; }
|
Returns the gateway instance with the specified ID .
|
6,885
|
public function set ( $ id , $ definition ) { unset ( $ this -> _gateways [ $ id ] ) ; if ( $ definition === null ) { unset ( $ this -> _definitions [ $ id ] ) ; return ; } if ( is_object ( $ definition ) || is_callable ( $ definition , true ) ) { $ this -> _definitions [ $ id ] = $ definition ; } elseif ( is_array ( $ definition ) ) { if ( isset ( $ definition [ 'class' ] ) ) { $ this -> _definitions [ $ id ] = $ definition ; } else { throw new InvalidConfigException ( "The configuration for the \"$id\" gateway must contain a \"class\" element." ) ; } } else { throw new InvalidConfigException ( "Unexpected configuration type for the \"$id\" gateway: " . gettype ( $ definition ) ) ; } }
|
Registers a gateway definition with this locator .
|
6,886
|
public function setGateways ( $ gateways ) { foreach ( $ gateways as $ id => $ gateway ) { $ this -> set ( $ id , $ gateway ) ; } }
|
Registers a set of gateway definitions in this locator .
|
6,887
|
protected function doGetInjectedDefinitions ( $ name , array & $ visited ) { if ( isset ( $ visited [ $ name ] ) ) { return ; } try { $ visited [ $ name ] = $ this -> proxy -> get ( $ name ) ; } catch ( RuntimeException $ e ) { return ; } catch ( MissingPropertyException $ e ) { return ; } foreach ( $ visited [ $ name ] -> getParams ( ) as $ param ) { if ( $ param instanceof GeneratorInstance ) { $ this -> doGetInjectedDefinitions ( $ param -> getName ( ) , $ visited ) ; } } foreach ( $ visited [ $ name ] -> getMethods ( ) as $ method ) { if ( isset ( $ method [ 'params' ] ) && is_array ( $ method [ 'params' ] ) ) { foreach ( $ method [ 'params' ] as $ param ) { if ( $ param instanceof GeneratorInstance ) { $ this -> doGetInjectedDefinitions ( $ param -> getName ( ) , $ visited ) ; } } } } }
|
Recursively looks for discovered dependencies
|
6,888
|
public function getFilter ( ) { $ filter = [ ] ; $ tag = $ this -> getRequest ( ) -> getVar ( "t" ) ; if ( $ tag ) { $ filter [ "Tags.URLSegment" ] = $ tag ; } $ this -> extend ( "updateFilter" , $ filter ) ; return $ filter ; }
|
Find a filter from the URL that we can apply to the products list
|
6,889
|
public function PaginatedProducts ( $ limit = 10 ) { $ products = $ this -> SortedProducts ( ) ; $ filter = $ this -> getFilter ( ) ; if ( count ( $ filter ) ) { $ products = $ products -> filter ( $ filter ) ; } return PaginatedList :: create ( $ products , $ this -> getRequest ( ) ) -> setPageLength ( $ limit ) ; }
|
Get a paginated list of products contained in this category
|
6,890
|
public function PaginatedAllProducts ( $ limit = 10 ) { $ products = $ this -> AllProducts ( ) ; $ filter = $ this -> getFilter ( ) ; if ( count ( $ filter ) ) { $ products = $ products -> filter ( $ filter ) ; } return PaginatedList :: create ( $ products , $ this -> getRequest ( ) ) -> setPageLength ( $ limit ) ; }
|
Get a paginated list of all products at this level and below
|
6,891
|
public function getViewer ( $ action ) { if ( isset ( $ this -> templates [ $ action ] ) && $ this -> templates [ $ action ] || ( isset ( $ this -> templates [ 'index' ] ) && $ this -> templates [ 'index' ] ) || $ this -> template ) { return parent :: getViewer ( $ action ) ; } if ( $ action == "index" ) { $ action = "" ; } else { $ action = '_' . $ action ; } $ templates = array_merge ( SSViewer :: get_templates_by_class ( get_class ( $ this -> dataRecord ) , $ action , "SilverStripe\\CMS\\Model\\SiteTree" ) , SSViewer :: get_templates_by_class ( Page :: singleton ( ) , $ action , "SilverStripe\\CMS\\Model\\SiteTree" ) , SSViewer :: get_templates_by_class ( static :: class , $ action , "SilverStripe\\Control\\Controller" ) , SSViewer :: get_templates_by_class ( get_class ( $ this -> dataRecord ) , "" , "SilverStripe\\CMS\\Model\\SiteTree" ) , SSViewer :: get_templates_by_class ( static :: class , "" , "SilverStripe\\Control\\Controller" ) ) ; return SSViewer :: create ( $ templates ) ; }
|
Overwrite default SSViewer call to get a custom template list
|
6,892
|
protected function alert ( \ AMQP \ Wire \ Reader $ args ) { $ replyCode = $ args -> readShort ( ) ; $ replyText = $ args -> readShortstr ( ) ; $ details = $ args -> readTable ( ) ; array_push ( $ this -> alerts , array ( $ replyCode , $ replyText , $ details ) ) ; }
|
This method allows the server to send a non - fatal warning to the client . This is used for methods that are normally asynchronous and thus do not have confirmations and for which the server may detect errors that need to be reported . Fatal errors are handled as channel or connection exceptions ; non - fatal errors are sent through this method .
|
6,893
|
protected function accessRequestOk ( \ AMQP \ Wire \ Reader $ args ) { $ this -> defaultTicket = $ args -> readShort ( ) ; return $ this -> defaultTicket ; }
|
grant access to server resources
|
6,894
|
protected function queueDeclareOk ( \ AMQP \ Wire \ Reader $ args ) { $ queue = $ args -> readShortstr ( ) ; $ messageCount = $ args -> readLong ( ) ; $ consumerCount = $ args -> readLong ( ) ; return array ( $ queue , $ messageCount , $ consumerCount ) ; }
|
confirms a queue definition
|
6,895
|
public function basicCancel ( $ consumerTag , $ nowait = false ) { $ args = $ this -> frameBuilder -> basicCancel ( $ consumerTag , $ nowait ) ; $ this -> sendMethodFrame ( array ( 60 , 30 ) , $ args ) ; return $ this -> wait ( array ( "60,31" ) ) ; }
|
end a queue consumer
|
6,896
|
public function basicQos ( $ prefetchSize , $ prefetchCount , $ aGlobal ) { $ args = $ this -> frameBuilder -> basicQos ( $ prefetchSize , $ prefetchCount , $ aGlobal ) ; $ this -> sendMethodFrame ( array ( 60 , 10 ) , $ args ) ; return $ this -> wait ( array ( "60,11" ) ) ; }
|
specify quality of service
|
6,897
|
public function basicRecover ( $ reQueue = false ) { $ args = $ this -> frameBuilder -> basicRecover ( $ reQueue ) ; $ this -> sendMethodFrame ( array ( 60 , 100 ) , $ args ) ; }
|
redeliver unacknowledged messages
|
6,898
|
public function basicReject ( $ deliveryTag , $ reQueue ) { $ args = $ this -> frameBuilder -> basicReject ( $ deliveryTag , $ reQueue ) ; $ this -> sendMethodFrame ( array ( 60 , 90 ) , $ args ) ; }
|
reject an incoming message
|
6,899
|
protected function basicReturn ( \ AMQP \ Wire \ Reader $ args ) { $ reply_code = $ args -> readShort ( ) ; $ reply_text = $ args -> readShortstr ( ) ; $ exchange = $ args -> readShortstr ( ) ; $ routing_key = $ args -> readShortstr ( ) ; $ msg = $ this -> wait ( ) ; }
|
return a failed message
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.