idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
31,000
public function getAlterTableInfo ( $ table , $ options ) { $ table = $ this -> buildRealTableName ( $ table ) ; return $ this -> getSchema ( ) -> getAlterTableInfo ( $ table , $ options ) ; }
get alter table info from options result is array keys has summary and sql
31,001
public function getAlterTableSql ( $ table , array $ options ) { $ table = $ this -> buildRealTableName ( $ table ) ; return $ this -> getSchema ( ) -> getAlterTableSql ( $ table , $ options ) ; }
get alter table sql from fields result is sql string
31,002
public function getDropTableSql ( $ table ) { $ table = $ this -> buildRealTableName ( $ table ) ; return $ this -> getSchema ( ) -> getDropTableSql ( $ table ) ; }
get drop table sql
31,003
public function parse ( $ query = null ) { $ query = $ this -> checkQuery ( $ query ) ; Ioc :: logger ( 'db' ) -> debug ( $ query -> all ( ) ) ; return $ this -> getParser ( ) -> parse ( $ query ) ; }
parse query option to sql
31,004
static public function install ( $ options , $ sql , $ adapterNamespace ) { $ adapterNamespace = ! empty ( $ adapterNamespace ) ? $ adapterNamespace : self :: $ adapterNamespace ; $ options [ 'adapter' ] = preg_replace ( '/[^A-Z0-9_\.-]/i' , '' , $ options [ 'adapter' ] ) ; $ class = self :: $ adapterNamespace . ucfirst ( strtolower ( $ options [ 'adapter' ] ) ) . 'Adapter' ; if ( ! class_exists ( $ class ) ) { throw new DbException ( 'The database adapter ' . $ class . ' is not valid.' ) ; } if ( strtolower ( $ options [ 'adapter' ] ) == 'sqlite' || strtolower ( $ options [ 'adapter' ] ) == 'pdo' ) { if ( ! file_exists ( $ options [ 'database' ] ) ) { touch ( $ options [ 'database' ] ) ; chmod ( $ options [ 'database' ] , 0777 ) ; } if ( ! file_exists ( $ options [ 'database' ] ) ) { throw new DbException ( 'Could not create the database file.' ) ; } } $ conn = new $ class ( $ options ) ; $ lines = file ( $ sql ) ; if ( count ( $ lines ) > 0 ) { $ insideComment = false ; foreach ( $ lines as $ i => $ line ) { if ( $ insideComment ) { if ( substr ( $ line , 0 , 2 ) == '*/' ) { $ insideComment = false ; } unset ( $ lines [ $ i ] ) ; } else { if ( ( substr ( $ line , 0 , 1 ) == '-' ) || ( substr ( $ line , 0 , 1 ) == '#' ) ) { unset ( $ lines [ $ i ] ) ; } else if ( substr ( $ line , 0 , 2 ) == '/*' ) { $ insideComment = true ; unset ( $ lines [ $ i ] ) ; } } } $ sqlString = trim ( implode ( '' , $ lines ) ) ; $ newLine = ( strpos ( $ sqlString , ";\r\n" ) !== false ) ? ";\r\n" : ";\n" ; $ statements = explode ( $ newLine , $ sqlString ) ; foreach ( $ statements as $ statement ) { if ( ! empty ( $ statement ) ) { if ( isset ( $ options [ 'table_prefix' ] ) ) { $ statement = str_replace ( '[{table_prefix}]' , $ options [ 'table_prefix' ] , trim ( $ statement ) ) ; } $ conn -> query ( $ statement ) ; } } } }
Install the database schema
31,005
static public function check ( $ options ) { $ error = ini_get ( 'error_reporting' ) ; error_reporting ( E_ERROR ) ; try { $ options [ 'adapter' ] = preg_replace ( '/[^A-Z0-9_\.-]/i' , '' , $ options [ 'adapter' ] ) ; $ class = self :: $ adapterNamespace . ucfirst ( strtolower ( $ options [ 'adapter' ] ) ) . 'Adapter' ; if ( ! class_exists ( $ class ) ) { return 'db adapter ' . $ class . ' is not valid.' ; } else { $ conn = new $ class ( $ db ) ; } error_reporting ( $ error ) ; return null ; } catch ( Exception $ e ) { error_reporting ( $ error ) ; return $ e -> getMessage ( ) ; } }
Check the database
31,006
public function index ( $ product_sku ) { $ product = Subbly :: api ( 'subbly.product' ) -> find ( $ product_sku ) ; $ options = $ this -> getParams ( 'offset' , 'limit' , 'includes' , 'order_by' ) ; $ productImages = Subbly :: api ( 'subbly.product_image' ) -> findByProduct ( $ product , $ options ) ; return $ this -> jsonCollectionResponse ( 'product_images' , $ productImages ) ; }
Get list of ProductImage for a Product .
31,007
public static function create_from_base ( Symfony_Request $ request ) { if ( $ request instanceof static ) { return $ request ; } $ content = $ request -> content ; $ request = ( new static ) -> duplicate ( $ request -> query -> all ( ) , $ request -> request -> all ( ) , $ request -> attributes -> all ( ) , $ request -> cookies -> all ( ) , $ request -> files -> all ( ) , $ request -> server -> all ( ) ) ; $ request -> content = $ content ; $ request -> request = $ request -> get_input_source ( ) ; return $ request ; }
Create an Request from a Symfony instance .
31,008
private function recursiveBuildFinalBlockTree ( BlockInterface $ block = null , BlockView $ view , & $ output = null ) { $ viewHash = spl_object_hash ( $ view ) ; $ blockHash = null ; if ( null !== $ block ) { $ blockHash = spl_object_hash ( $ block ) ; } elseif ( isset ( $ this -> blocksByView [ $ viewHash ] ) ) { $ blockHash = $ this -> blocksByView [ $ viewHash ] ; } $ output = isset ( $ this -> dataByView [ $ viewHash ] ) ? $ this -> dataByView [ $ viewHash ] : [ ] ; if ( null !== $ blockHash ) { $ output = array_replace ( $ output , isset ( $ this -> dataByBlock [ $ blockHash ] ) ? $ this -> dataByBlock [ $ blockHash ] : [ ] ) ; } $ this -> validateViewIds ( $ block , $ view ) ; $ output [ 'children' ] = [ ] ; foreach ( $ view -> children as $ name => $ childView ) { $ childBlock = null !== $ block && $ block -> has ( $ name ) ? $ block -> get ( $ name ) : null ; $ childHash = spl_object_hash ( $ childView ) ; $ output [ 'children' ] [ $ childHash ] = [ ] ; $ this -> recursiveBuildFinalBlockTree ( $ childBlock , $ childView , $ output [ 'children' ] [ $ childHash ] ) ; } }
Recursive build final block tree .
31,009
private function validateViewIds ( BlockInterface $ block = null , BlockView $ view ) { if ( ! $ block -> getOption ( 'render_id' ) ) { return ; } $ id = $ view -> vars [ 'id' ] ; $ hash = spl_object_hash ( $ block ) ; $ newIds = [ $ hash ] ; if ( isset ( $ this -> viewIds [ $ id ] ) && ! \ in_array ( $ hash , $ this -> viewIds [ $ id ] ) ) { $ this -> data [ 'duplicate_ids' ] [ ] = $ id ; $ this -> data [ 'duplicate_ids' ] = array_unique ( $ this -> data [ 'duplicate_ids' ] ) ; $ newIds = array_merge ( $ this -> viewIds [ $ id ] , $ newIds ) ; } $ this -> viewIds [ $ id ] = $ newIds ; }
Validate the view Id .
31,010
public function index ( ) { $ options = $ this -> getParams ( 'offset' , 'limit' , 'includes' , 'order_by' ) ; $ orders = Subbly :: api ( 'subbly.order' ) -> all ( $ options ) ; return $ this -> jsonCollectionResponse ( 'orders' , $ orders ) ; }
Get Order list .
31,011
public function show ( $ sku ) { $ options = $ this -> getParams ( 'includes' ) ; $ order = Subbly :: api ( 'subbly.order' ) -> find ( $ sku , $ options ) ; return $ this -> jsonResponse ( array ( 'order' => $ this -> presenter -> single ( $ order ) , ) ) ; }
Get Order datas .
31,012
protected function tilNextMillis ( $ lastTimestamp ) { $ timestamp = $ this -> timeGen ( ) ; while ( $ timestamp <= $ lastTimestamp ) { $ timestamp = $ this -> timeGen ( ) ; } return $ timestamp ; }
get next micro time
31,013
protected function handle ( ) { $ token = $ this -> tokens -> current ( ) ; $ this -> preIndent ( ) ; if ( isset ( self :: $ map [ $ token [ 0 ] ] ) ) { $ this -> result .= self :: $ map [ $ token [ 0 ] ] ; } else { if ( DocLexer :: T_STRING === $ token [ 0 ] ) { $ this -> result .= '"' . $ token [ 1 ] . '"' ; } else { $ this -> result .= $ token [ 1 ] ; } } $ this -> postIndent ( ) ; }
Processes the current token .
31,014
private function indent ( $ force = false ) { if ( $ this -> size || $ force ) { $ this -> result .= $ this -> break ; } if ( $ this -> size ) { $ this -> result .= str_repeat ( $ this -> char , $ this -> size * $ this -> level ) ; } }
Adds indentation to the result .
31,015
private function postIndent ( ) { $ next = $ this -> tokens -> getId ( $ this -> tokens -> key ( ) + 1 ) ; switch ( $ this -> tokens -> getId ( ) ) { case DocLexer :: T_COLON : if ( $ this -> space ) { $ this -> result .= ' ' ; } break ; case DocLexer :: T_COMMA : if ( ( DocLexer :: T_CLOSE_CURLY_BRACES !== $ next ) && ( DocLexer :: T_CLOSE_PARENTHESIS !== $ next ) ) { $ this -> indent ( ) ; } break ; case DocLexer :: T_OPEN_CURLY_BRACES : $ this -> level ++ ; if ( DocLexer :: T_CLOSE_CURLY_BRACES !== $ next ) { $ this -> indent ( ) ; } break ; case DocLexer :: T_OPEN_PARENTHESIS : $ this -> level ++ ; if ( DocLexer :: T_CLOSE_PARENTHESIS !== $ next ) { $ this -> indent ( ) ; } break ; } }
Handles indentation after the current token .
31,016
private function preIndent ( ) { $ prev = $ this -> tokens -> getId ( $ this -> tokens -> key ( ) - 1 ) ; switch ( $ this -> tokens -> getId ( ) ) { case DocLexer :: T_AT : if ( $ prev && ( DocLexer :: T_COLON !== $ prev ) && ( DocLexer :: T_COMMA !== $ prev ) && ( DocLexer :: T_EQUALS !== $ prev ) && ( DocLexer :: T_OPEN_CURLY_BRACES !== $ prev ) && ( DocLexer :: T_OPEN_PARENTHESIS !== $ prev ) ) { $ this -> indent ( true ) ; } break ; case DocLexer :: T_CLOSE_CURLY_BRACES : $ this -> level -- ; if ( DocLexer :: T_OPEN_CURLY_BRACES !== $ prev ) { $ this -> indent ( ) ; } break ; case DocLexer :: T_CLOSE_PARENTHESIS : $ this -> level -- ; if ( DocLexer :: T_OPEN_PARENTHESIS !== $ prev ) { $ this -> indent ( ) ; } break ; } }
Handles indentation before the current token .
31,017
public function Width ( ) { if ( ! ( $ this -> width > 0 ) ) $ this -> width = \ imagesx ( $ this -> resource ) ; return $ this -> width ; }
Image width in pixels
31,018
public function Height ( ) { if ( ! ( $ this -> height > 0 ) ) $ this -> height = \ imagesy ( $ this -> resource ) ; return $ this -> height ; }
Image height in pixels
31,019
function CenterSquarify ( ArgbColor $ backgroundColor = null ) { $ width = $ this -> Width ( ) ; $ height = $ this -> Height ( ) ; $ squareSize = min ( $ width , $ height ) ; $ xOrigin = 0 ; $ yOrigin = 0 ; if ( $ width > $ squareSize ) $ xOrigin = round ( ( $ width - $ squareSize ) / 2 ) ; else if ( $ height > $ squareSize ) $ yOrigin = round ( ( $ height - $ squareSize ) / 2 ) ; $ destRes = \ imagecreatetruecolor ( $ squareSize , $ squareSize ) ; if ( $ backgroundColor ) { $ colRes = \ imagecolorallocate ( $ destRes , $ backgroundColor -> GetRed ( ) , $ backgroundColor -> GetGreen ( ) , $ backgroundColor -> GetBlue ( ) ) ; \ imagefill ( $ destRes , 0 , 0 , $ colRes ) ; \ imagecolordeallocate ( $ destRes , $ colRes ) ; } \ imagecopy ( $ destRes , $ this -> resource , 0 , 0 , $ xOrigin , $ yOrigin , $ squareSize , $ squareSize ) ; $ this -> AssignResource ( $ destRes ) ; }
Crops the image to the biggest fitting centered square
31,020
function ScaleDown ( $ maxSize ) { $ height = $ this -> Height ( ) ; $ width = $ this -> Width ( ) ; if ( $ width < $ maxSize && $ height < $ maxSize ) return ; $ xRatio = $ maxSize / $ height ; $ yRatio = $ maxSize / $ width ; $ this -> ScaleProportional ( min ( $ xRatio , $ yRatio ) ) ; }
Scales down with fixed relation to the max size in height and width ; If image is smaller nothing is done .
31,021
function Scale ( $ newWidth , $ newHeight ) { $ dstImg = \ imagecreatetruecolor ( $ newWidth , $ newHeight ) ; \ imagecopyresampled ( $ dstImg , $ this -> resource , 0 , 0 , 0 , 0 , $ newWidth , $ newHeight , $ this -> Width ( ) , $ this -> Height ( ) ) ; $ this -> AssignResource ( $ dstImg ) ; }
Scales to new size
31,022
protected function authorize ( Doozr_Acl_Service $ aclConsumer , Doozr_Acl_Service $ aclProvider ) { if ( $ aclProvider -> isLoginRequired ( ) === true && $ aclConsumer -> isLoggedIn ( ) === false ) { throw new Doozr_Base_Model_Rest_Exception ( 'Authorization required.' , 403 ) ; } elseif ( $ aclConsumer -> isAllowed ( $ aclProvider , Doozr_Acl_Service :: ACTION_CREATE ) === false ) { throw new Doozr_Base_Model_Rest_Exception ( 'Authorization required.' , 401 ) ; } else { $ status = true ; } return $ status ; }
Authorizes an consumer ACL service object against an provider ACL service object to check if resource is allowed for current consumer ...
31,023
protected function verbToOperation ( $ verb ) { switch ( strtoupper ( $ verb ) ) { case Doozr_Http :: REQUEST_METHOD_POST : $ operation = 'create' ; break ; case Doozr_Http :: REQUEST_METHOD_GET : $ operation = 'read' ; break ; case Doozr_Http :: REQUEST_METHOD_PUT : $ operation = 'update' ; break ; case Doozr_Http :: REQUEST_METHOD_DELETE : $ operation = 'delete' ; break ; case Doozr_Http :: REQUEST_METHOD_OPTIONS : $ operation = 'options' ; break ; case Doozr_Http :: REQUEST_METHOD_HEAD : $ operation = 'meta' ; break ; default : $ operation = 'read' ; break ; } return $ operation ; }
Returns the operation for passed in HTTP - verb .
31,024
protected function mergeArguments ( $ routeArguments , $ requestArguments ) { $ input = array ( $ routeArguments , $ requestArguments ) ; $ output = [ ] ; foreach ( $ input as $ keyValueStore ) { foreach ( $ keyValueStore as $ key => $ value ) { $ output [ $ this -> escape ( $ key ) ] = strval ( $ value ) ; } } return $ output ; }
Merges arguments retrieved from route with arguments retrieved normally with request .
31,025
protected function getMethodByVerbAndRoute ( $ verb , array $ route ) { $ method = $ this -> verbToOperation ( $ verb ) ; foreach ( $ route as $ node ) { $ method .= ucfirst ( $ this -> escape ( $ node ) ) ; } return $ method ; }
Converts a passed in HTTP - verb and a route to a Model - Method - Name which can be called to process the data .
31,026
public function configureServiceManager ( ServiceManager $ serviceManager ) { foreach ( $ this -> config as $ key => $ value ) { switch ( $ key ) { case 'factories' : $ this -> configureFactories ( $ serviceManager , $ value ) ; break ; } } }
Configure service manager
31,027
protected function __init ( ) { $ events = $ this -> event ( ) ; $ events -> on ( ModuleManagerEvents \ EventModuleResolve :: EVENT_NAME , new ModuleManager \ Events \ ModuleResolve \ ListenerResolverDefault , 100 ) ; $ events -> on ( ModuleManagerEvents \ EventModuleResolve :: EVENT_NAME , new ModuleManager \ Events \ ModuleResolve \ ListenerResolverDirectory , 90 ) ; $ events -> on ( ModuleManagerEvents \ EventModuleInitialize :: EVENT_NAME , new ModuleManager \ Events \ ModuleInitialize \ ListenerInitInitialization , 1000 ) ; $ events -> on ( ModuleManagerEvents \ EventModuleInitialize :: EVENT_NAME , new ModuleManager \ Events \ ModuleInitialize \ ListenerInitServices , 900 ) ; $ events -> on ( ModuleManagerEvents \ EventModuleInitialize :: EVENT_NAME , new ModuleManager \ Events \ ModuleInitialize \ ListenerInitNestedContainer ) ; $ events -> on ( EventHeapOfModuleManager :: EVENT_MODULES_POSTLOAD , new ModuleManager \ Events \ ModulesPostLoad \ ListenerRegisterActions , - 100 ) ; $ events -> on ( EventHeapOfModuleManager :: EVENT_MODULES_POSTLOAD , new ModuleManager \ Events \ ModulesPostLoad \ ListenerInstantiateMergedConfig , - 500 ) ; $ events -> on ( EventHeapOfModuleManager :: EVENT_MODULES_POSTLOAD , new ModuleManager \ Events \ ModulesPostLoad \ ListenerGrabRegisteredServices , - 1000 ) ; $ events -> on ( EventHeapOfModuleManager :: EVENT_MODULES_POSTLOAD , new ModuleManager \ Events \ ModuleInitialize \ ListenerInitSapiEvents , - 10000 ) ; }
Attach default listeners
31,028
function setModulesDir ( $ modulesDir ) { if ( is_string ( $ modulesDir ) ) $ modulesDir = array ( $ modulesDir ) ; $ this -> modulesDir = array_merge ( $ this -> modulesDir , $ modulesDir ) ; return $ this ; }
Set Modules Default Directory
31,029
function setDirMap ( array $ moduleMap ) { if ( ! empty ( $ moduleMap ) && array_values ( $ moduleMap ) === $ moduleMap ) throw new \ Exception ( 'Module map must be associative array, module name and class map.' ) ; foreach ( $ moduleMap as $ m => $ v ) { if ( strstr ( $ v , '/' ) !== false || strstr ( $ v , '\\' ) !== false ) { $ v = rtrim ( $ v , "\\/" ) ; $ v = str_replace ( '\\' , '/' , $ v ) ; $ moduleMap [ $ m ] = $ v ; } } $ this -> dirMap = array_merge ( $ this -> dirMap , $ moduleMap ) ; return $ this ; }
Set Module Name Dir Map
31,030
protected function normalizePassword ( ? string $ password ) : ? string { if ( $ password === null ) { return null ; } return $ this -> percentEncode ( $ password ) ; }
Normaliza o valor do password indicado .
31,031
public function add_to ( $ email , $ name = null ) { if ( $ this -> addressee_exists ( $ email , [ 'to' ] ) ) { return ; } $ this -> recipients [ 'to' ] [ ] = [ 'name' => $ name , 'email' => strtolower ( $ email ) , ] ; }
Add recipient TO
31,032
public function add_reply_to ( $ email , $ name = null ) { foreach ( $ this -> reply_to as $ reply_to ) { if ( $ reply_to [ 'email' ] == $ email ) { return ; } } $ this -> reply_to [ ] = [ 'name' => $ name , 'email' => strtolower ( $ email ) , ] ; }
Add reply to
31,033
private function addressee_exists ( string $ addressee , array $ lists = [ ] ) : bool { foreach ( $ this -> recipients as $ recipient_list => $ recipients ) { if ( in_array ( $ recipient_list , $ lists ) or count ( $ lists ) === 0 ) { foreach ( $ recipients as $ recipient ) { if ( $ recipient [ 'email' ] == $ addressee ) { return true ; } } } } return false ; }
Check whether an address exists in the address lists
31,034
public function runCallback ( \ Closure $ callback ) { if ( $ this -> runningCallback ) { throw new RuntimeException ( 'Started recursive callback in legacy kernel.' ) ; } $ this -> runningCallback = true ; $ platformHome = getcwd ( ) ; chdir ( $ platformHome . '/innomatic_legacy' ) ; try { require_once getcwd ( ) . '/innomatic/core/classes/innomatic/core/RootContainer.php' ; $ rootContainer = \ Innomatic \ Core \ RootContainer :: instance ( '\Innomatic\Core\RootContainer' ) ; $ rootContainer -> setServiceContainer ( $ this -> container ) ; $ innomatic = \ Innomatic \ Core \ InnomaticContainer :: instance ( '\Innomatic\Core\InnomaticContainer' ) ; $ innomatic -> setInterface ( \ Innomatic \ Core \ InnomaticContainer :: INTERFACE_CONSOLE ) ; $ home = \ Innomatic \ Core \ RootContainer :: instance ( '\Innomatic\Core\RootContainer' ) -> getHome ( ) . 'innomatic/' ; $ innomatic -> bootstrap ( $ home , $ home . 'core/conf/innomatic.ini' ) ; $ result = $ innomatic -> runCallback ( $ callback ) ; } catch ( Exception $ e ) { chdir ( $ platformHome ) ; $ this -> runningCallback = false ; throw $ e ; } chdir ( $ platformHome ) ; $ this -> runningCallback = false ; return $ result ; }
Runs a callback function in the legacy core .
31,035
private function setEncodePassword ( User $ user , $ plainPassword ) { $ password = $ this -> encoderFactory -> getEncoder ( $ user ) -> encodePassword ( $ plainPassword , $ user -> getSalt ( ) ) ; $ user -> setPassword ( $ password ) ; }
Encode plain password
31,036
public function run ( $ args ) { $ args = $ this -> parseArgs ( $ args ) ; if ( ! isset ( $ args [ 0 ] ) || ! $ args [ 0 ] ) { return $ this -> updateEverything ( ) ; } $ projectName = $ args [ 0 ] ; if ( ! $ this -> existsProjectName ( $ projectName ) ) { return $ this -> error ( '&required-project' ) ; } echo $ this -> info ( "Update project '{$projectName}'" ) ; return $ this -> exec ( 'update' , 'update-project' , [ $ projectName ] ) ; }
Run update command .
31,037
private function updateEverything ( ) { $ env = basename ( $ this -> cwd ) ; echo "\n> $env\n----------------------------\n" ; $ this -> exec ( 'update' , 'update-root-project' ) ; $ path = $ this -> cwd . '/' . $ this -> projectsDir ; foreach ( scandir ( $ path ) as $ projectName ) { if ( $ projectName [ 0 ] != '.' && is_dir ( $ path . '/' . $ projectName ) ) { echo "\n> $projectName\n----------------------------\n" ; $ this -> exec ( 'update' , 'update-project' , [ $ projectName ] ) ; } } }
Update everything inside working directory .
31,038
public static function belongsTo ( $ modelClass , $ columnName , $ options = [ ] ) { $ options [ 'type' ] = self :: BELONGS_TO ; $ options [ 'modelClass' ] = $ modelClass ; $ options [ 'compares' ] = [ [ ( false === strpos ( $ columnName , '.' ) ) ? "t.$columnName" : $ columnName , "r." . $ modelClass :: getDb ( ) -> getTablePk ( $ modelClass :: getTableName ( ) ) , "=" ] ] ; return new self ( $ options ) ; }
Create s a belongsTo relation
31,039
public static function hasOne ( $ modelClass , $ columnName , $ options = [ ] ) { $ options [ 'type' ] = self :: HAS_ONE ; $ options [ 'modelClass' ] = $ modelClass ; $ options [ 'compares' ] = [ [ "t.__PK__" , ( false === strpos ( $ columnName , '.' ) ) ? "r.$columnName" : $ columnName , "=" ] ] ; return new self ( $ options ) ; }
Creates a hasOne relation
31,040
public static function hasMany ( $ modelClass , $ columnName , $ options = [ ] ) { $ options [ 'type' ] = self :: HAS_MANY ; $ options [ 'modelClass' ] = $ modelClass ; $ options [ 'compares' ] = [ [ "t.__PK__" , ( false === strpos ( $ columnName , '.' ) ) ? "r.$columnName" : $ columnName , "=" ] ] ; return new self ( $ options ) ; }
Creates a hasMany relation
31,041
public static function manyToMany ( $ modelClass , $ connection , $ options = [ ] ) { $ options [ 'type' ] = self :: MANY_TO_MANY ; $ options [ 'modelClass' ] = $ modelClass ; $ connection = explode ( '(' , $ connection ) ; $ table = $ connection [ 0 ] ; list ( $ c1 , $ c2 ) = explode ( ',' , $ connection [ 1 ] ) ; $ r = new self ( $ options ) ; $ c1 = trim ( $ c1 ) ; $ c2 = trim ( $ c2 ) ; $ r -> join ( trim ( $ table ) , [ [ "t.__PK__" , "j.$c1" , "=" ] ] ) -> compare ( [ "j.$c2" => "r." . $ modelClass :: getDb ( ) -> getTablePk ( $ modelClass :: getTableName ( ) ) ] ) ; return $ r ; }
Creates a many2many relation
31,042
public function getCondition ( $ name , $ models = null ) { $ this -> _afterConditionParams = $ this -> _afterConditionJoins = [ ] ; if ( is_null ( $ models ) ) { return $ this -> _calcJoin ( ) ; } elseif ( ! is_array ( $ models ) ) { $ models = [ $ models ] ; } return $ this -> _calcModels ( $ models ) ; }
If no models are sent will return for initial join if not it will return a new query for selected models ;
31,043
protected function output ( ) { $ content = $ this -> getContentRaw ( ) ; foreach ( $ content as $ logEntry ) { $ content = $ logEntry [ 'time' ] . ' ' . '[' . $ logEntry [ 'type' ] . '] ' . $ logEntry [ 'fingerprint' ] . ' ' . $ logEntry [ 'message' ] . $ this -> lineBreak . $ this -> getLineSeparator ( ) . $ this -> lineBreak ; if ( $ this -> getPersistent ( ) === true ) { $ this -> getFilesystem ( ) -> pwrite ( $ this -> getLogfile ( ) , $ content , $ this -> getAppend ( ) ) ; } else { $ this -> getFilesystem ( ) -> write ( $ this -> getLogfile ( ) , $ content , $ this -> getAppend ( ) ) ; } } $ this -> clearContent ( ) ; }
Output method for writing files . We need this method cause it differs here from abstract default .
31,044
public function setAllow ( $ allow ) { if ( ! is_array ( $ allow ) ) { $ allow = array ( $ allow ) ; } foreach ( $ allow as $ verb ) { $ this -> getAcl ( ) -> addPermission ( $ this -> verbToOperation ( $ verb ) ) ; } $ this -> allow = $ allow ; }
Setter for allowed HTTP verbs
31,045
public function getRealRoute ( $ asString = false ) { return ( $ asString === true ) ? implode ( '/' , $ this -> realRoute ) : $ this -> realRoute ; }
Getter for real route
31,046
public function updateAccount ( $ request , $ match ) { $ model = Pluf_Shortcuts_GetObjectOr404 ( 'User_Account' , $ request -> user -> id ) ; $ form = Pluf_Shortcuts_GetFormForUpdateModel ( $ model , $ request -> REQUEST , array ( ) ) ; return $ form -> save ( ) ; }
Updates account information of current user
31,047
public function deleteAccount ( $ request , $ match ) { $ user = Pluf_Shortcuts_GetObjectOr404 ( 'User' , $ request -> user -> id ) ; $ request -> user -> delete ( ) ; return $ user ; }
Delete account of current user .
31,048
public function build ( ) : Client { return new Client ( new CommandBus ( [ new LockingMiddleware ( ) , new ExceptionMiddleware ( ) , new ValidationMiddleware ( ) , new CommandHandlerMiddleware ( new ClassNameExtractor ( ) , new CallableLocator ( $ this -> getCommandResolver ( ) ) , new ClassNameWithoutSuffixInflector ( 'Request' ) ) ] ) ) ; }
Build the webservices client .
31,049
public function setServiceEndpoint ( string $ endpoint ) : AbstractClientBuilder { if ( ! filter_var ( $ endpoint , FILTER_VALIDATE_URL ) || parse_url ( $ endpoint , PHP_URL_SCHEME ) !== 'https' ) { throw new \ InvalidArgumentException ( 'Incorrect endpoint given' ) ; } $ this -> endpoint = $ endpoint ; return $ this ; }
Set endpoint for SOAP service .
31,050
private function loadComponent ( ) { $ component = false ; $ currentPath = Request :: getRequestPath ( __BASE ) ; $ defaultPath = false ; if ( file_exists ( __APP_CONFIG_COMPONENTS ) ) { $ componentsData = json_decode ( file_get_contents ( __APP_CONFIG_COMPONENTS ) , true ) ; if ( ! is_array ( $ componentsData ) ) throw new PlinthException ( 'Cannot parse components.json config' ) ; foreach ( $ componentsData as $ label => $ data ) { $ loadedComponent = Component :: loadFromArray ( __APP_CONFIG_PATH , $ label , $ data ) ; if ( $ loadedComponent -> getPath ( ) === false ) { if ( $ defaultPath === false ) $ defaultPath = true ; else throw new PlinthException ( 'Their can only be one default path in components.json config' ) ; } if ( $ loadedComponent -> matchesCurrentPath ( $ currentPath ) ) { if ( $ component === false || $ loadedComponent -> getDepth ( ) > $ component -> getDepth ( ) ) $ component = $ loadedComponent ; } } } $ this -> component = $ component ; }
Load all components and activate the correct one
31,051
private function loadSettings ( ) { $ userdefinedsettings = $ this -> initialConfig -> get ( 'settings' ) ? : [ ] ; $ this -> initialSettings = new Settings ( ) ; $ this -> initialSettings -> loadSettings ( $ userdefinedsettings ) ; $ userdefinedsettings = $ this -> config -> get ( 'settings' ) ? : [ ] ; $ this -> settings = new Settings ( ) ; $ this -> settings -> loadSettings ( $ userdefinedsettings ) ; }
Load all application settings from the config file
31,052
private function handleSessions ( ) { if ( $ this -> getRouter ( ) -> hasRoute ( ) ) { if ( ! $ this -> getRouter ( ) -> getRoute ( ) -> isPublic ( ) || $ this -> getRouter ( ) -> getRoute ( ) -> allowSessions ( ) ) { if ( $ this -> getSetting ( 'userservice' ) ) { try { if ( $ this -> getSetting ( 'userclass' ) === false ) throw new PlinthException ( 'Please define a user class and user repository' ) ; $ this -> getUserService ( ) -> setUserRepository ( $ this -> getEntityRepository ( ) -> getRepository ( $ this -> getSetting ( 'userclass' ) ) ) ; session_start ( ) ; } catch ( PlinthException $ e ) { throw $ e ; } } else { session_start ( ) ; } } } }
Handle session_start when needed
31,053
private function registerLogger ( ) { $ path = $ this -> config -> get ( 'logger:path' ) ? : __LOGGING_PATH ; if ( ! file_exists ( $ path ) ) throw new PlinthException ( 'Logging directory does not exist' ) ; $ this -> _logger = KLogger :: instance ( $ path , KLogger :: INFO ) ; $ mail = $ this -> config -> get ( 'logger:mail' ) ; if ( is_array ( $ mail ) ) { foreach ( $ mail as $ name => $ address ) { $ this -> _logger -> addMailing ( $ address , $ name ) ; } } register_shutdown_function ( [ KLogger :: class , 'handleShutdown' ] , $ this -> _logger ) ; }
Register the logger service
31,054
private function loadDatabases ( ) { $ databaseKeys = $ this -> config -> get ( 'databases:keys' ) ? : [ ] ; if ( ! isset ( $ databaseKeys [ 'database' ] ) ) $ databaseKeys [ ] = 'database' ; foreach ( $ databaseKeys as $ databaseKey ) { $ database = $ this -> config -> get ( $ databaseKey ) ; if ( $ database !== false ) $ this -> initConnection ( $ database , $ databaseKey ) ; $ this -> config -> destroy ( $ databaseKey ) ; unset ( $ database ) ; } }
Load the different database connections
31,055
private function registerClasses ( ) { $ this -> addValidator ( self :: DEFAULT_VALIDATOR_LABEL , new Validator ( $ this ) ) ; $ this -> setEntityRepository ( new EntityRepository ( $ this ) ) ; $ this -> setResponse ( new Response ( $ this ) ) ; $ this -> setDict ( new Dictionary ( $ this ) ) ; $ this -> setStore ( new Store ( $ this ) ) ; $ this -> setBin ( new Bin ( $ this ) ) ; $ this -> setUserService ( new UserService ( $ this ) ) ; $ this -> setRouter ( new Router ( $ this ) ) ; }
Register the necessary connector classes
31,056
private function handleSessionConfig ( ) { $ cookiePath = __BASE ; if ( $ this -> component !== false && ! $ this -> component -> usesRootCookiePath ( ) ) { $ cookiePath .= $ this -> component -> getPath ( ) ; } session_set_cookie_params ( 0 , $ cookiePath ) ; if ( $ this -> settings -> getSetting ( "sessionsavepath" ) !== false ) { session_save_path ( __BASE_ROOT . $ this -> settings -> getSetting ( "sessionsavepath" ) ) ; } }
Register different session paths for the different components
31,057
private function executeHandlers ( ) { $ this -> state = self :: STATE_HANDLING ; $ this -> handleRouter ( ) ; $ this -> handleSessions ( ) ; $ this -> handleLogout ( ) ; $ this -> handleDictionary ( $ _COOKIE , $ this -> getSetting ( 'fallbacklocale' ) ) ; }
Handle the necessary services
31,058
public function handleRouter ( ) { if ( $ this -> component === false || $ this -> component -> getMergeDefaultRouting ( ) ) { $ this -> getRouter ( ) -> loadRoutes ( __APP_CONFIG_ROUTING , ! $ this -> getSetting ( 'forcelogin' , true ) , $ this -> getSetting ( 'forcesession' , true ) , $ this -> getSetting ( 'templatebase' , true ) , $ this -> getSetting ( 'templatepath' , true ) ) ; } if ( $ this -> component !== false ) { $ this -> getRouter ( ) -> loadRoutes ( $ this -> component -> hasRouting ( ) ? $ this -> component -> getRoutingPath ( ) : __APP_CONFIG_ROUTING , ! $ this -> getSetting ( 'forcelogin' ) , $ this -> getSetting ( 'forcesession' ) , $ this -> getSetting ( 'templatebase' ) , $ this -> getSetting ( 'templatepath' ) ) ; } $ this -> getRouter ( ) -> handleRoute ( __BASE ) ; }
Load and handle the application routing
31,059
public function handleLogout ( ) { if ( Request :: get ( 'logout' ) !== null ) { $ this -> getUserService ( ) -> logout ( ) ; header ( 'Location: ' . __BASE_URL . preg_replace ( '/(logout&|\?logout$|&logout$)/' , '' , Request :: getRequestPath ( __BASE , false ) ) ) ; exit ; } }
Handle user logout
31,060
private function handleDictionaryService ( $ fallback = false ) { $ dictionaryServiceClass = $ this -> getSetting ( "dictionaryservice" ) ; $ dictionaryServiceMerge = $ this -> getSetting ( "dictionarymerge" ) ; if ( $ dictionaryServiceClass !== false ) { if ( class_exists ( $ dictionaryServiceClass ) ) { $ dictionaryService = new $ dictionaryServiceClass ( $ this ) ; $ this -> getDict ( ) -> loadFromArray ( $ dictionaryService -> loadTranslations ( $ this -> getLang ( ) ) , $ dictionaryServiceMerge ) ; if ( Language :: validate ( $ fallback ) === $ fallback ) { $ this -> getDict ( ) -> loadFromArray ( $ dictionaryService -> loadTranslations ( $ fallback ) , $ dictionaryServiceMerge , true ) ; } } else { throw new PlinthException ( "Your dictionary service implementation, $dictionaryServiceClass, cannot be found." ) ; } } return $ this ; }
Handle the user defined dictionary service if present
31,061
protected function signatureToArray ( $ method , $ signature , $ cleanup = true ) { $ begin = strpos ( $ signature , '(' ) + 1 ; $ end = strrpos ( $ signature , ')' ) ; $ signature = substr ( $ signature , $ begin , $ end - $ begin ) ; $ arguments = explode ( ',' , $ signature ) ; $ result = [ ] ; $ i = 1 ; foreach ( $ arguments as $ argument ) { $ argument = trim ( $ argument ) ; if ( $ cleanup === true ) { if ( stristr ( $ argument , ' ' ) !== false && strtolower ( substr ( $ argument , 0 , 5 ) ) != 'array' ) { $ argument = explode ( ' ' , $ argument ) ; $ result [ $ i ] = $ argument ; } } else { $ result [ $ i ] = $ argument ; } ++ $ i ; } return [ $ method => $ result ] ; }
Parses a given signature of a method for arguments and returns result as array .
31,062
public function getRelative ( $ root ) { if ( $ root instanceof FileObject ) { $ root = $ root -> getFullName ( ) ; } else { $ root = rtrim ( $ this -> getSafePath ( $ root ) , '/' ) ; } if ( strpos ( $ this -> fullName , $ root ) === 0 ) { return substr ( $ this -> fullName , strlen ( $ root ) ) ; } return false ; }
GET RELATIVE PATH BUT PATH MUST BE ROOT S CHILD
31,063
public function parseMailDefinition ( $ xml , $ locale = null ) { $ this -> validator -> validate ( $ xml , $ this -> xsdFile ) ; $ parsed = simplexml_load_string ( $ xml ) ; $ message = new ParsedMessage ( ) ; $ from = $ parsed -> from ; if ( $ from -> count ( ) > 0 ) { $ message -> setFrom ( ( string ) $ from , ( string ) $ from -> attributes ( ) [ 'name' ] ) ; } $ replyTo = $ parsed -> replyTo ; if ( $ replyTo -> count ( ) > 0 ) { $ message -> setReplyTo ( ( string ) $ replyTo ) ; } foreach ( $ parsed -> to as $ to ) { $ message -> addTo ( ( string ) $ to , ( string ) $ to -> attributes ( ) [ 'name' ] ) ; } foreach ( $ parsed -> cc as $ cc ) { $ message -> addCc ( ( string ) $ cc , ( string ) $ cc -> attributes ( ) [ 'name' ] ) ; } foreach ( $ parsed -> bcc as $ bcc ) { $ message -> addBcc ( ( string ) $ bcc , ( string ) $ bcc -> attributes ( ) [ 'name' ] ) ; } $ message -> setSubject ( $ this -> getLocalizedTagContent ( $ parsed -> subject , $ locale ) ) ; $ message -> setMessageHtml ( $ this -> getLocalizedTagContent ( $ parsed -> messageHtml , $ locale ) ) ; $ message -> setMessageText ( $ this -> getLocalizedTagContent ( $ parsed -> messageText , $ locale ) ) ; return $ message ; }
Parse XML Mail Definition string
31,064
public function profile ( $ class , $ methodName , array $ methodArguments = null , $ invocations = 1 ) { if ( true === is_object ( $ class ) ) { $ className = get_class ( $ class ) ; } else { $ className = $ class ; if ( false === class_exists ( $ className ) ) { throw new Doozr_Exception ( sprintf ( '%s does not exist.' , $ className ) ) ; } } $ method = new \ ReflectionMethod ( $ className , $ methodName ) ; $ instance = null ; if ( true === $ method -> isStatic ( ) ) { $ this -> profileStatic = true ; } elseif ( false === $ method -> isStatic ( ) && ! ( $ class instanceof $ className ) ) { $ class = new \ ReflectionClass ( $ className ) ; $ instance = $ class -> newInstance ( ) ; } else { $ instance = $ class ; } $ durations = [ ] ; for ( $ i = 0 ; $ i < $ invocations ; ++ $ i ) { $ start = microseconds ( ) ; if ( is_null ( $ methodArguments ) ) { $ method -> invoke ( $ instance ) ; } else { $ method -> invokeArgs ( $ instance , $ methodArguments ) ; } $ durations [ ] = microseconds ( ) - $ start ; } $ total = round ( array_sum ( $ durations ) , 8 ) ; return $ this -> profilingDetails ( [ 'class' => $ className , 'method' => $ methodName , 'arguments' => $ methodArguments , 'duration' => [ 'microseconds' => [ 'total' => $ total , 'average' => round ( $ total / count ( $ durations ) , 8 ) , 'worst' => round ( max ( $ durations ) , 8 ) , ] , 'seconds' => [ 'total' => $ total / 1000 , 'average' => round ( $ total / 1000 / count ( $ durations ) , 8 ) , 'worst' => round ( max ( $ durations ) / 1000 , 8 ) , ] , ] , 'invocations' => $ invocations , ] ) ; }
Runs a method with the provided arguments for profiling .
31,065
public function getProfilingReport ( $ print = false ) { if ( null !== $ details = $ this -> getProfilingDetails ( ) ) { $ methodName = $ this -> invokedMethod ( ) ; $ countInvocations = $ details [ 'invocations' ] ; if ( 1 === $ countInvocations ) { $ report = sprintf ( '%s took %ss' , $ methodName , $ details [ 'duration' ] [ 'microseconds' ] [ 'average' ] ) ; } else { $ report = sprintf ( '%s was invoked %s times\n' , $ methodName , $ countInvocations ) ; $ report .= sprintf ( 'Total duration: %sms\n' , $ details [ 'duration' ] [ 'microseconds' ] [ 'total' ] ) ; $ report .= sprintf ( 'Average duration: %sms\n' , $ details [ 'duration' ] [ 'microseconds' ] [ 'average' ] ) ; $ report .= sprintf ( 'Worst duration: %sms\n' , $ details [ 'duration' ] [ 'microseconds' ] [ 'worst' ] ) ; } if ( true === $ print ) { echo $ report ; } } return $ report ; }
Prints out profilingDetails about the last profiled method .
31,066
protected function invokedMethod ( ) { $ result = null ; if ( null !== $ details = $ this -> getProfilingDetails ( ) ) { if ( true === $ this -> profileStatic ) { $ scopeResolution = '::' ; } else { $ scopeResolution = '->' ; } if ( null !== $ this -> getProfilingDetails ( ) [ 'arguments' ] ) { $ arguments = implode ( ', ' , $ details [ 'arguments' ] ) ; } else { $ arguments = '' ; } $ result = sprintf ( '%s%s%s("%s")' , $ details [ 'class' ] , $ scopeResolution , $ details [ 'method' ] , $ arguments ) ; } return $ result ; }
Returns a string representing the last invoked method .
31,067
function GetStatus ( ) { if ( IO \ File :: Exists ( $ this -> targetFile ) ) { $ json = IO \ File :: GetContents ( $ this -> targetFile ) ; return json_decode ( $ json ) ; } return null ; }
Gets the current status
31,068
public function getLayout ( & $ content ) { $ res = preg_match ( "/\{layout\s+(.+)\}/" , $ content , $ match ) ; if ( $ res ) { return str_replace ( array ( '"' , '\'' , '.html' ) , '' , $ match [ 1 ] ) ; } return null ; }
get layout from template content if not set return null .
31,069
private function parse_all ( & $ str ) { $ str = preg_replace ( "/\{php\s+([^\}]+)\}/" , "<?php \\1?>" , $ str ) ; $ str = preg_replace ( "/\{if\s+(.+?)\}/" , "<?php if(\\1) { ?>" , $ str ) ; $ str = preg_replace ( "/\{else\}/" , "<?php } else { ?>" , $ str ) ; $ str = preg_replace ( "/\{elseif\s+(.+?)\}/" , "<?php } elseif (\\1) { ?>" , $ str ) ; $ str = preg_replace ( "/\{\/if\}/" , "<?php } ?>" , $ str ) ; $ str = preg_replace ( "/\{for\s+\(?(.+?)\)?\}/" , "<?php for(\\1) { ?>" , $ str ) ; $ str = preg_replace ( "/\{\/for\}/" , "<?php } ?>" , $ str ) ; $ str = preg_replace ( "/\{(foreach|loop)\s+\(((\S+).+?)\)\}/" , "<?php if(isset(\\3) && is_array(\\3)) foreach(\\2) { ?>" , $ str ) ; $ str = preg_replace ( "/\{(foreach|loop)\s+(\S+)\s+(?:as\s+)*(\S+)\}/" , "<?php if(isset(\\2) && is_array(\\2)) foreach(\\2 as \\3) {?>" , $ str ) ; $ str = preg_replace ( "/\{(foreach|loop)\s+(\S+)\s+(?:as\s+)*(\S+)\s+(\S+)\}/" , "<?php if(isset(\\2) && is_array(\\2)) foreach(\\2 as \\3 => \\4){?>" , $ str ) ; $ str = preg_replace ( "/\{\/(foreach|loop)\}/" , "<?php } ?>" , $ str ) ; $ str = preg_replace ( "/\{\+\+(.+?)\}/" , "<?php ++\\1; ?>" , $ str ) ; $ str = preg_replace ( "/\{\-\-(.+?)\}/" , "<?php ++\\1; ?>" , $ str ) ; $ str = preg_replace ( "/\{(.+?)\+\+\}/" , "<?php \\1++; ?>" , $ str ) ; $ str = preg_replace ( "/\{(.+?)\-\-\}/" , "<?php \\1--; ?>" , $ str ) ; $ str = preg_replace_callback ( "/\{widget:?([\w\:]+)?\s+([^}]+)\}/i" , array ( $ this , 'widget_callback' ) , $ str ) ; $ str = preg_replace_callback ( "/\{\/widget[^}]*\}/i" , array ( $ this , 'end_widget_callback' ) , $ str ) ; $ str = preg_replace_callback ( "/\{(template|include|layout)\s+(.+)\}/" , array ( $ this , 'parse_callback' ) , $ str ) ; $ str = $ this -> parse_fun_var ( $ str ) ; return $ str ; }
parse content to php code
31,070
private function func_arr_params_callback ( $ matches ) { $ func = $ matches [ 1 ] ; $ params_str = $ matches [ 2 ] ; $ in_matches = [ ] ; preg_match_all ( "/([a-z_]+)\=[\"\']?([^\"\']+)[\"\']?/i" , stripslashes ( $ params_str ) , $ in_matches , PREG_SET_ORDER ) ; $ params = null ; foreach ( $ in_matches as $ v ) { $ params [ $ v [ 1 ] ] = $ v [ 2 ] ; } return "<?php print_r( " . $ func . "(" . ArrayHelper :: toRaw ( $ params ) . ') ); ?>' ; }
function array params
31,071
static public function setCookie ( $ name , $ value , $ expire = '3600' , $ path = null , $ domain = null , $ secure = null , $ httponly = null ) { $ expire = $ expire ? time ( ) + ( is_numeric ( $ expire ) ? intval ( $ expire ) : intval ( self :: $ COOKIE_EXPIRE ) ) : 0 ; if ( empty ( $ path ) ) $ path = '/' ; if ( empty ( $ domain ) ) $ domain = self :: $ COOKIE_DOMAIN ? self :: $ COOKIE_DOMAIN : UriHelper :: GetRootDomain ( ) ; $ secure = is_null ( $ secure ) ? static :: $ COOKIE_SECURE : ( bool ) $ secure ; $ httponly = is_null ( $ httponly ) ? static :: $ COOKIE_HTTP_ONLY : ( bool ) $ httponly ; $ name = static :: $ COOKIE_PREFIX . $ name ; $ result = setcookie ( $ name , $ value , $ expire , $ path , $ domain , $ secure , $ httponly ) ; $ _COOKIE [ $ name ] = $ value ; }
set cookie need think cross domain .
31,072
static public function getCookie ( $ name = null ) { if ( $ name ) $ name = static :: $ COOKIE_PREFIX . $ name ; return empty ( $ name ) ? $ _COOKIE : ( isset ( $ _COOKIE [ $ name ] ) ? $ _COOKIE [ $ name ] : '' ) ; }
get cookie need think cross domain .
31,073
static public function isMobile ( ) { if ( isset ( $ _SERVER [ 'HTTP_VIA' ] ) || isset ( $ _SERVER [ 'HTTP_X_NOKIA_CONNECTION_MODE' ] ) || isset ( $ _SERVER [ 'HTTP_X_UP_CALLING_LINE_ID' ] ) || isset ( $ _SERVER [ 'HTTP_ACCEPT' ] ) && strpos ( strtoupper ( $ _SERVER [ 'HTTP_ACCEPT' ] ) , "VND.WAP.WML" ) > 0 ) { return true ; } $ browser = isset ( $ _SERVER [ 'HTTP_USER_AGENT' ] ) ? trim ( $ _SERVER [ 'HTTP_USER_AGENT' ] ) : '' ; $ clientkeywords = array ( 'nokia' , 'sony' , 'ericsson' , 'mot' , 'samsung' , 'htc' , 'sgh' , 'lg' , 'sharp' , 'sie-' , 'philips' , 'panasonic' , 'alcatel' , 'lenovo' , 'iphone' , 'ipod' , 'blackberry' , 'meizu' , 'android' , 'netfront' , 'symbian' , 'ucweb' , 'windowsce' , 'palm' , 'operamini' , 'operamobi' , 'opera mobi' , 'openwave' , 'nexusone' , 'cldc' , 'midp' , 'wap' , 'mobile' ) ; if ( preg_match ( "/(" . implode ( '|' , $ clientkeywords ) . ")/i" , $ browser ) && strpos ( $ browser , 'ipad' ) === false ) { return TRUE ; } else { return FALSE ; } }
if http is mobile
31,074
static public function getClientIp ( ) { if ( getenv ( 'HTTP_CLIENT_IP' ) && strcasecmp ( getenv ( 'HTTP_CLIENT_IP' ) , 'unknown' ) ) { $ ip = getenv ( 'HTTP_CLIENT_IP' ) ; } elseif ( getenv ( 'HTTP_X_FORWARDED_FOR' ) && strcasecmp ( getenv ( 'HTTP_X_FORWARDED_FOR' ) , 'unknown' ) ) { $ ip = getenv ( 'HTTP_X_FORWARDED_FOR' ) ; } elseif ( getenv ( 'REMOTE_ADDR' ) && strcasecmp ( getenv ( 'REMOTE_ADDR' ) , 'unknown' ) ) { $ ip = getenv ( 'REMOTE_ADDR' ) ; } elseif ( isset ( $ _SERVER [ 'REMOTE_ADDR' ] ) && $ _SERVER [ 'REMOTE_ADDR' ] && strcasecmp ( $ _SERVER [ 'REMOTE_ADDR' ] , 'unknown' ) ) { $ ip = $ _SERVER [ 'REMOTE_ADDR' ] ; } else { return '0.0.0.0' ; } return preg_match ( '/[\d\.]{7,15}/' , $ ip , $ matches ) ? $ matches [ 0 ] : '0.0.0.0' ; }
get client ip
31,075
static public function checkClientIp ( array $ allowed_ips = [ ] ) { array_unshift ( $ allowed_ips , '127.0.0.1' ) ; $ ip = static :: getClientIp ( ) ; $ check_ip_arr = explode ( '.' , $ ip ) ; if ( ! in_array ( $ ip , $ allowed_ips ) ) { foreach ( $ allowed_ips as $ val ) { if ( strpos ( $ val , '*' ) !== false ) { $ arr = explode ( '.' , $ val ) ; $ bl = true ; for ( $ i = 0 ; $ i < 4 ; $ i ++ ) { if ( $ arr [ $ i ] != '*' ) { if ( $ arr [ $ i ] != $ check_ip_arr [ $ i ] ) { $ bl = false ; break ; } } } if ( $ bl ) { return true ; } } } return false ; } return true ; }
check client ip is legal .
31,076
public function findByLocale ( string $ locale ) : ICollection { $ builder = $ this -> builder ( ) -> innerJoin ( '_pages' , '[_locales]' , 'l' , '_pages.localeId = l.id' ) -> andWhere ( '[url] IS NOT NULL' ) -> andWhere ( '[visible] = %i' , 1 ) -> andWhere ( '[l.name] = %s' , $ locale ) ; return $ this -> toCollection ( $ builder ) ; }
Vrati lokalizovane stranky bez HP
31,077
public function getByUrl ( ? string $ url , $ locale ) : ? Page { $ orm = $ this -> getRepository ( ) -> getModel ( ) ; if ( $ locale instanceof Locale ) { $ eLocale = $ locale ; } else { $ eLocale = $ orm -> locales -> getByLocale ( $ locale ) ; } $ urls = $ this -> getPageList ( ) ; if ( isset ( $ urls [ $ url ] ) ) { $ builder = $ this -> builder ( ) -> andWhere ( '[id] = %i' , $ urls [ $ url ] ) -> andWhere ( '[localeId] = %i' , $ eLocale -> id ) ; return $ this -> toEntity ( $ builder ) ; } return null ; }
Vrati stranku podle url
31,078
public function exists ( string $ url = null ) : bool { $ urls = $ this -> getPageList ( ) ; if ( isset ( $ urls [ $ url ] ) ) { return true ; } else { return false ; } }
Je URL v databazi
31,079
public function forceUniqueUserNames ( ) { $ userLoginIndex = $ this -> db -> get_row ( "SHOW INDEX FROM " . $ this -> db -> users . " WHERE Key_name = 'user_login_key' AND Non_unique = 1" ) ; if ( is_object ( $ userLoginIndex ) && ! empty ( $ userLoginIndex ) ) { $ this -> db -> query ( "ALTER TABLE " . $ this -> db -> users . " DROP INDEX user_login_key" ) ; $ this -> db -> query ( "ALTER TABLE " . $ this -> db -> users . " ADD UNIQUE user_login_key (user_login);" ) ; } }
Force user account to have a unique username Why this is not default is unknown at the moment .
31,080
public function mailLogging ( $ line , $ severity ) { if ( count ( $ this -> mailingList ) > 0 ) { $ To = implode ( ', ' , $ this -> mailingList ) ; $ Body = $ line ; $ Subject = "[LOGGING] Severity: $severity" ; $ CustomHeaders = 'MIME-Version: 1.0' . "\r\n" ; $ CustomHeaders .= 'X-Priority: 1 (Highest)' . "\r\n" ; $ CustomHeaders .= 'X-MSMail-Priority: High' . "\r\n" ; $ CustomHeaders .= 'Importance: High' . "\r\n" ; $ CustomHeaders .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n" ; @ mail ( $ To , $ Subject , $ Body , $ CustomHeaders ) ; } }
Mails a log line to the receivers to alert them
31,081
public static function handleShutdown ( $ self ) { $ error = error_get_last ( ) ; if ( $ error !== NULL ) { $ errno = $ error [ "type" ] ; $ errfile = $ error [ "file" ] ; $ errline = $ error [ "line" ] ; $ errstr = $ error [ "message" ] ; $ logstr = " ($errno): $errstr in $errfile on line $errline" ; switch ( $ errno ) { case E_CORE_ERROR : $ self -> logEmerg ( "Core fatal error" . $ logstr ) ; break ; case E_COMPILE_ERROR : $ self -> logAlert ( "Compile fatal error" . $ logstr ) ; break ; case E_ERROR : $ self -> logCrit ( "Fatal error" . $ logstr ) ; break ; case E_PARSE : $ self -> logCrit ( "Parse error" . $ logstr ) ; break ; case E_USER_ERROR : $ self -> logCrit ( "User fatal error" . $ logstr ) ; break ; case E_RECOVERABLE_ERROR : $ self -> logCrit ( "Recoverable fatal error" . $ logstr ) ; break ; case E_ALL : $ self -> logError ( "Error" . $ logstr ) ; break ; case E_WARNING : $ self -> logWarn ( "Warning" . $ logstr ) ; break ; case E_CORE_WARNING : $ self -> logWarn ( "Core warning" . $ logstr ) ; break ; case E_COMPILE_WARNING : $ self -> logWarn ( "Compile warning" . $ logstr ) ; break ; case E_USER_WARNING : $ self -> logWarn ( "User warning" . $ logstr ) ; break ; case E_DEPRECATED : $ self -> logWarn ( "Deprecated" . $ logstr ) ; break ; case E_USER_DEPRECATED : $ self -> logWarn ( "User deprecated" . $ logstr ) ; break ; case E_NOTICE : $ self -> logNotice ( "Notice" . $ logstr ) ; break ; case E_USER_NOTICE : $ self -> logNotice ( "User notice" . $ logstr ) ; break ; case E_STRICT : $ self -> logNotice ( "Strict notice" . $ logstr ) ; break ; default : $ self -> logError ( "Unknown error" . $ logstr ) ; } } }
When the webserver finishes the request or the script crashes on an error this function will fetch the last error and log it .
31,082
public static function update ( Event $ event ) { $ dbFilename = PHPReleases :: getLocation ( ) ; self :: maybeCreateDBFolder ( dirname ( $ dbFilename ) ) ; $ io = $ event -> getIO ( ) ; $ io -> write ( 'Fetching change logs from official PHP website...' , false ) ; $ io -> write ( ' PHP5...' , false ) ; $ php5 = self :: downloadFile ( self :: PHP_5_RELEASES ) ; $ io -> write ( ' PHP7...' , false ) ; $ php7 = self :: downloadFile ( self :: PHP_7_RELEASES ) ; $ io -> write ( ' done!' , true ) ; $ releases = array ( ) ; $ io -> write ( 'Parsing change logs to extract versions...' , false ) ; $ io -> write ( ' PHP5...' , false ) ; $ php5Releases = self :: parseReleases ( $ php5 ) ; $ io -> write ( '(' . count ( $ php5Releases ) . ' releases)' , false ) ; $ releases = array_merge ( $ releases , $ php5Releases ) ; $ io -> write ( ' PHP7...' , false ) ; $ php7Releases = self :: parseReleases ( $ php7 ) ; $ io -> write ( '(' . count ( $ php7Releases ) . ' releases)' , false ) ; $ releases = array_merge ( $ releases , $ php7Releases ) ; $ io -> write ( ' done!' , true ) ; ksort ( $ releases , SORT_NATURAL ) ; self :: generateConfig ( $ releases , $ dbFilename ) ; $ io -> write ( 'The PHP Releases database has been updated.' , true ) ; }
Update the stored database .
31,083
protected static function downloadFile ( $ url ) { $ options = array ( CURLOPT_RETURNTRANSFER => true , CURLOPT_TIMEOUT => 600 , CURLOPT_URL => $ url , ) ; $ curl = curl_init ( ) ; curl_setopt_array ( $ curl , $ options ) ; $ result = curl_exec ( $ curl ) ; curl_close ( $ curl ) ; return $ result ; }
Download a file from an URL .
31,084
protected static function parseReleases ( $ html ) { $ releases = array ( ) ; $ xmlErrorHandling = libxml_use_internal_errors ( true ) ; $ dom = new DOMDocument ( ) ; $ dom -> loadHTML ( $ html ) ; $ xpath = new DOMXPath ( $ dom ) ; $ nodes = self :: getByClass ( 'version' , $ xpath ) ; foreach ( $ nodes as $ node ) { $ version = $ node -> getAttribute ( 'id' ) ; if ( 1 !== preg_match ( self :: SKIP_PATTERN , $ version ) ) { $ date = '' ; $ dateNodes = self :: getByClass ( 'releasedate' , $ xpath , $ node ) ; foreach ( $ dateNodes as $ dateNode ) { $ date = $ dateNode -> getAttribute ( 'datetime' ) ; } $ releases [ $ version ] = empty ( $ date ) ? '' : $ date ; } } libxml_clear_errors ( ) ; libxml_use_internal_errors ( $ xmlErrorHandling ) ; return ( array ) $ releases ; }
Parse a PHP change log web page to extract PHP releases .
31,085
protected static function generateConfig ( $ releases , $ phpFile ) { $ data = '<?php' . PHP_EOL ; $ data .= '// DO NOT EDIT! This file has been automatically generated.' . PHP_EOL ; $ data .= '// Run composer update to fetch a new version.' . PHP_EOL ; $ data .= 'return array(' . PHP_EOL ; foreach ( $ releases as $ version => $ date ) { $ data .= ' \'' . $ version . '\' => \'' . $ date . '\',' . PHP_EOL ; } $ data .= ');' . PHP_EOL ; file_put_contents ( $ phpFile , $ data ) ; }
Generate a PHP configuration file from the CSV data file .
31,086
public function getServerVersion ( ) { try { $ version = $ this -> pdo -> getAttribute ( \ PDO :: ATTR_SERVER_VERSION ) ; } catch ( \ PDOException $ e ) { return NULL ; } return $ version ; }
Get the server software version .
31,087
public function Equals ( Enum $ rhs = null ) { return $ rhs != null && get_class ( $ rhs ) == get_class ( $ this ) && $ rhs -> Value ( ) === $ this -> Value ( ) ; }
Checks if right hand side has the same class and value as this
31,088
static function ByValue ( $ value ) { $ calledClass = get_called_class ( ) ; $ allowed = self :: AllowedClassValues ( $ calledClass ) ; if ( ! in_array ( $ value , $ allowed , true ) ) throw new \ InvalidArgumentException ( 'Value ' . $ value . ' not allowed for enum ' . $ calledClass ) ; return new $ calledClass ( $ value ) ; }
Creates the enum by value
31,089
static function ByCreationMethod ( $ name ) { $ enumClass = new \ ReflectionClass ( get_class ( ) ) ; $ calledClass = get_called_class ( ) ; $ reflectionClass = new \ ReflectionClass ( $ calledClass ) ; $ methods = $ reflectionClass -> getMethods ( \ ReflectionMethod :: IS_STATIC ) ; foreach ( $ methods as $ method ) { if ( $ method -> name != $ name ) continue ; if ( $ method -> isPublic ( ) && $ method -> getNumberOfParameters ( ) == 0 ) { if ( ! $ enumClass -> hasMethod ( $ method -> name ) ) { $ result = $ method -> invoke ( null ) ; if ( get_class ( $ result ) == $ calledClass ) return $ result ; } } } throw new \ InvalidArgumentException ( "'Creation method '$name' not found" ) ; }
Searches the creation method with the given name and invokes it
31,090
private static function AllowedClassValues ( $ calledClass ) { if ( ! isset ( self :: $ allowedValues [ $ calledClass ] ) ) { $ values = array ( ) ; $ enumClass = new \ ReflectionClass ( get_class ( ) ) ; $ reflectionClass = new \ ReflectionClass ( $ calledClass ) ; $ methods = $ reflectionClass -> getMethods ( \ ReflectionMethod :: IS_STATIC ) ; foreach ( $ methods as $ method ) { if ( $ method -> isPublic ( ) && $ method -> getNumberOfParameters ( ) == 0 ) { if ( ! $ enumClass -> hasMethod ( $ method -> name ) ) { $ result = $ method -> invoke ( null ) ; if ( get_class ( $ result ) == $ calledClass ) $ values [ ] = $ result -> Value ( ) ; } } } self :: $ allowedValues [ $ calledClass ] = $ values ; } return self :: $ allowedValues [ $ calledClass ] ; }
Returns the allowed values for the given class
31,091
public function drupalFormValidate ( $ values , $ storage ) { $ this -> populateFromDrupalForm ( $ values , $ storage ) ; list ( $ errors , $ warnings ) = $ this -> validate ( $ values ) ; foreach ( $ values as $ field => $ value ) { $ parts = explode ( '__' , $ field ) ; if ( count ( $ parts ) != 4 || $ parts [ 1 ] !== 'sm' || $ parts [ 2 ] != 'configurable_to_drupal' ) { continue ; } list ( $ direction , $ discard , $ column_name , $ i ) = $ parts ; $ action = $ storage [ 'synch_mapping_fields' ] [ $ direction ] [ $ i ] [ 'action' ] ; $ tokens = array ( ) ; $ row_mappings = array ( ) ; foreach ( array ( 'remove' , 'configurable_to_drupal' , 'configurable_to_ldap' , 'convert' , 'direction' , 'ldap_attr' , 'user_attr' , 'user_tokens' ) as $ column_name ) { $ input_name = join ( '__' , array ( 'sm' , $ column_name , $ i ) ) ; $ row_mappings [ $ column_name ] = isset ( $ values [ $ input_name ] ) ? $ values [ $ input_name ] : NULL ; } $ has_values = $ row_mappings [ 'ldap_attr' ] || $ row_mappings [ 'user_attr' ] ; if ( $ has_values ) { $ tokens [ '%ldap_attr' ] = $ row_mappings [ 'ldap_attr' ] ; $ row_descriptor = t ( "server %sid row mapping to ldap attribute %ldap_attr" , $ tokens ) ; $ tokens [ '!row_descriptor' ] = $ row_descriptor ; if ( ! $ row_mappings [ 'direction' ] ) { $ input_name = join ( '__' , array ( 'sm' , 'direction' , $ i ) ) ; $ errors [ $ input_name ] = t ( 'No mapping direction given in !row_descriptor' , $ tokens ) ; } if ( $ direction == LDAP_USER_PROV_DIRECTION_TO_DRUPAL_USER && $ row_mappings [ 'user_attr' ] == 'user_tokens' ) { $ input_name = join ( '__' , array ( 'sm' , 'user_attr' , $ i ) ) ; $ errors [ $ input_name ] = t ( 'User tokens not allowed when mapping to Drupal user. Location: !row_descriptor' , $ tokens ) ; } if ( ! $ row_mappings [ 'ldap_attr' ] ) { $ input_name = join ( '__' , array ( 'sm' , 'ldap_attr' , $ i ) ) ; $ errors [ $ input_name ] = t ( 'No ldap attribute given in !row_descriptor' , $ tokens ) ; } if ( ! $ row_mappings [ 'user_attr' ] ) { $ input_name = join ( '__' , array ( 'sm' , 'user_attr' , $ i ) ) ; $ errors [ $ input_name ] = t ( 'No user attribute given in !row_descriptor' , $ tokens ) ; } } } return array ( $ errors , $ warnings ) ; }
validate submitted form
31,092
protected function populateFromDrupalForm ( $ values , $ storage ) { $ this -> drupalAcctProvisionServer = ( $ values [ 'drupalAcctProvisionServer' ] == 'none' ) ? 0 : $ values [ 'drupalAcctProvisionServer' ] ; $ this -> ldapEntryProvisionServer = ( $ values [ 'ldapEntryProvisionServer' ] == 'none' ) ? 0 : $ values [ 'ldapEntryProvisionServer' ] ; $ this -> drupalAcctProvisionTriggers = $ values [ 'drupalAcctProvisionTriggers' ] ; $ this -> ldapEntryProvisionTriggers = $ values [ 'ldapEntryProvisionTriggers' ] ; $ this -> orphanedDrupalAcctBehavior = $ values [ 'orphanedDrupalAcctBehavior' ] ; $ this -> orphanedCheckQty = $ values [ 'orphanedCheckQty' ] ; $ this -> manualAccountConflict = $ values [ 'manualAccountConflict' ] ; $ this -> userConflictResolve = ( $ values [ 'userConflictResolve' ] ) ? ( int ) $ values [ 'userConflictResolve' ] : NULL ; $ this -> acctCreation = ( $ values [ 'acctCreation' ] ) ? ( int ) $ values [ 'acctCreation' ] : NULL ; $ this -> disableAdminPasswordField = $ values [ 'disableAdminPasswordField' ] ; $ this -> ldapUserSynchMappings = $ this -> synchMappingsFromForm ( $ values , $ storage ) ; }
populate object with data from form values
31,093
private function synchMappingsFromForm ( $ values , $ storage ) { $ mappings = array ( ) ; foreach ( $ values as $ field => $ value ) { $ parts = explode ( '__' , $ field ) ; if ( count ( $ parts ) != 4 || $ parts [ 1 ] !== 'sm' ) { continue ; } list ( $ direction , $ discard , $ column_name , $ i ) = $ parts ; $ action = $ storage [ 'synch_mapping_fields' ] [ $ direction ] [ $ i ] [ 'action' ] ; $ row_mappings = array ( ) ; foreach ( array ( 'remove' , 'configurable_to_drupal' , 'configurable_to_ldap' , 'convert' , 'ldap_attr' , 'user_attr' , 'user_tokens' ) as $ column_name ) { $ input_name = join ( '__' , array ( $ direction , 'sm' , $ column_name , $ i ) ) ; $ row_mappings [ $ column_name ] = isset ( $ values [ $ input_name ] ) ? $ values [ $ input_name ] : NULL ; } if ( $ row_mappings [ 'remove' ] ) { continue ; } $ key = ( $ direction == LDAP_USER_PROV_DIRECTION_TO_DRUPAL_USER ) ? $ row_mappings [ 'user_attr' ] : $ row_mappings [ 'ldap_attr' ] ; if ( $ row_mappings [ 'configurable_to_drupal' ] && $ row_mappings [ 'ldap_attr' ] && $ row_mappings [ 'user_attr' ] ) { $ mappings [ $ direction ] [ $ key ] = array ( 'ldap_attr' => $ row_mappings [ 'ldap_attr' ] , 'user_attr' => $ row_mappings [ 'user_attr' ] , 'convert' => $ row_mappings [ 'convert' ] , 'direction' => $ direction , 'user_tokens' => $ row_mappings [ 'user_tokens' ] , 'config_module' => 'ldap_user' , 'prov_module' => 'ldap_user' , 'enabled' => 1 , ) ; $ synchEvents = ( $ direction == LDAP_USER_PROV_DIRECTION_TO_DRUPAL_USER ) ? $ this -> provisionsDrupalEvents : $ this -> provisionsLdapEvents ; foreach ( $ synchEvents as $ prov_event => $ discard ) { $ input_name = join ( '__' , array ( $ direction , 'sm' , $ prov_event , $ i ) ) ; if ( isset ( $ values [ $ input_name ] ) && $ values [ $ input_name ] ) { $ mappings [ $ direction ] [ $ key ] [ 'prov_events' ] [ ] = $ prov_event ; } } } } return $ mappings ; }
Extract synch mappings array from mapping table in admin form .
31,094
public function drupalFormSubmit ( $ values , $ storage ) { $ this -> populateFromDrupalForm ( $ values , $ storage ) ; try { $ save_result = $ this -> save ( ) ; } catch ( Exception $ e ) { $ this -> errorName = 'Save Error' ; $ this -> errorMsg = t ( 'Failed to save object. Your form data was not saved.' ) ; $ this -> hasError = TRUE ; } }
method to respond to successfully validated form submit .
31,095
private function addServerMappingFields ( & $ form , $ direction ) { if ( $ direction == LDAP_USER_PROV_DIRECTION_NONE ) { return ; } $ text = ( $ direction == LDAP_USER_PROV_DIRECTION_TO_DRUPAL_USER ) ? 'target' : 'source' ; $ user_attr_options = array ( '0' => t ( 'Select' ) . ' ' . $ text ) ; if ( ! empty ( $ this -> synchMapping [ $ direction ] ) ) { foreach ( $ this -> synchMapping [ $ direction ] as $ target_id => $ mapping ) { if ( ! isset ( $ mapping [ 'name' ] ) || isset ( $ mapping [ 'exclude_from_mapping_ui' ] ) && $ mapping [ 'exclude_from_mapping_ui' ] ) { continue ; } if ( ( isset ( $ mapping [ 'configurable_to_drupal' ] ) && $ mapping [ 'configurable_to_drupal' ] && $ direction == LDAP_USER_PROV_DIRECTION_TO_DRUPAL_USER ) || ( isset ( $ mapping [ 'configurable_to_ldap' ] ) && $ mapping [ 'configurable_to_ldap' ] && $ direction == LDAP_USER_PROV_DIRECTION_TO_LDAP_ENTRY ) ) { $ user_attr_options [ $ target_id ] = substr ( $ mapping [ 'name' ] , 0 , 25 ) ; } } } $ user_attr_options [ 'user_tokens' ] = '-- user tokens --' ; $ row = 0 ; foreach ( $ this -> synchMapping [ $ direction ] as $ target_id => $ mapping ) { if ( isset ( $ mapping [ 'exclude_from_mapping_ui' ] ) && $ mapping [ 'exclude_from_mapping_ui' ] ) { continue ; } if ( ! $ this -> isMappingConfigurable ( $ mapping , 'ldap_user' ) && ( $ mapping [ 'direction' ] == $ direction || $ mapping [ 'direction' ] == LDAP_USER_PROV_DIRECTION_ALL ) ) { $ this -> addSynchFormRow ( $ form , 'nonconfigurable' , $ direction , $ mapping , $ user_attr_options , $ row ) ; $ row ++ ; } } if ( ! empty ( $ this -> ldapUserSynchMappings [ $ direction ] ) ) { foreach ( $ this -> ldapUserSynchMappings [ $ direction ] as $ target_attr_token => $ mapping ) { if ( isset ( $ mapping [ 'enabled' ] ) && $ mapping [ 'enabled' ] && $ this -> isMappingConfigurable ( $ this -> synchMapping [ $ direction ] [ $ target_attr_token ] , 'ldap_user' ) ) { $ this -> addSynchFormRow ( $ form , 'update' , $ direction , $ mapping , $ user_attr_options , $ row ) ; $ row ++ ; } } } for ( $ i = 0 ; $ i < 4 ; $ i ++ ) { $ this -> addSynchFormRow ( $ form , 'add' , $ direction , NULL , $ user_attr_options , $ row ) ; $ row ++ ; } }
add existing mappings to ldap user provisioning mapping admin form table
31,096
private function isMappingConfigurable ( $ mapping = NULL , $ module = 'ldap_user' ) { $ configurable = ( ( ( ! isset ( $ mapping [ 'configurable_to_drupal' ] ) && ! isset ( $ mapping [ 'configurable_to_ldap' ] ) ) || ( isset ( $ mapping [ 'configurable_to_drupal' ] ) && $ mapping [ 'configurable_to_drupal' ] ) || ( isset ( $ mapping [ 'configurable_to_ldap' ] ) && $ mapping [ 'configurable_to_ldap' ] ) ) && ( ! isset ( $ mapping [ 'config_module' ] ) || ( isset ( $ mapping [ 'config_module' ] ) && $ mapping [ 'config_module' ] == $ module ) ) ) ; return $ configurable ; }
Is a mapping configurable by a given module?
31,097
private function provisionEventConfigurable ( $ prov_event , $ mapping = NULL ) { if ( $ mapping ) { if ( $ prov_event == LDAP_USER_EVENT_CREATE_LDAP_ENTRY || $ prov_event == LDAP_USER_EVENT_SYNCH_TO_LDAP_ENTRY ) { $ configurable = ( boolean ) ( ! isset ( $ mapping [ 'configurable_to_ldap' ] ) || $ mapping [ 'configurable_to_ldap' ] ) ; } elseif ( $ prov_event == LDAP_USER_EVENT_CREATE_DRUPAL_USER || $ prov_event == LDAP_USER_EVENT_SYNCH_TO_DRUPAL_USER ) { $ configurable = ( boolean ) ( ! isset ( $ mapping [ 'configurable_to_drupal' ] ) || $ mapping [ 'configurable_to_drupal' ] ) ; } } else { $ configurable = TRUE ; } return $ configurable ; }
Is a particular synch method viable for a given mapping? That is Can it be enabled in the UI by admins?
31,098
public function generatePartnerName ( PersonalDetails $ personalDetails ) { $ parts = array ( ) ; foreach ( array ( 'initials' , 'prefix' , 'lastname' ) as $ part ) { if ( '' !== ( $ value = ( string ) $ personalDetails -> { 'get' . ucfirst ( $ part ) } ( ) ) ) $ parts [ ] = $ value ; } return join ( ' ' , $ parts ) ; }
Generates and returns the name of the partner
31,099
public function activate ( Composer $ composer , IOInterface $ io ) : void { $ this -> installer = new Installer ( $ io , $ composer ) ; $ this -> vendorPath = $ composer -> getConfig ( ) -> get ( 'vendor-dir' ) ; $ composer -> getInstallationManager ( ) -> addInstaller ( $ this -> installer ) ; }
Called after the plugin is loaded