idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
13,900
protected function before ( ) { if ( $ this -> connection -> getDatabasePlatform ( ) instanceof SQLServerPlatform ) { $ this -> connection -> executeUpdate ( 'EXEC sp_msforeachtable "ALTER TABLE ? NOCHECK CONSTRAINT all"' ) ; } else if ( $ this -> connection -> getDatabasePlatform ( ) instanceof MySqlPlatform ) { $ thi...
Executed before the import is started
13,901
protected function after ( ) { if ( $ this -> connection -> getDatabasePlatform ( ) instanceof SQLServerPlatform ) { $ this -> connection -> executeUpdate ( 'exec sp_msforeachtable "ALTER TABLE ? WITH CHECK CHECK CONSTRAINT all"' ) ; } else if ( $ this -> connection -> getDatabasePlatform ( ) instanceof MySqlPlatform )...
Executed after the import is finished
13,902
public function hydrate ( $ puppetModules , $ group ) { $ availableClasses = [ ] ; if ( ! empty ( $ puppetModules ) ) { foreach ( $ puppetModules as $ puppetModule ) { if ( $ puppetModule -> hasClasses ( ) ) { foreach ( $ puppetModule -> getClasses ( ) as $ puppetClass ) { $ groupClass = $ group -> getClassByName ( $ p...
Hydrate group with the provided puppet modules data .
13,903
public function addFilter ( CollectionInterface $ collection , $ typeAlias , $ name , array $ options = [ ] ) { $ filter = $ this -> filterCreator -> create ( $ typeAlias , $ name , $ options ) ; $ collection -> addFilter ( $ filter ) ; return $ filter ; }
Adds a filter to the collection .
13,904
public function createNamedForm ( $ name , CollectionInterface $ collection , array $ rootFormBuilderOptions = [ ] , array $ filterFormBuilderOptions = [ ] , Request $ request = null ) { $ form = $ this -> formCreator -> createNamed ( $ name , $ collection , $ rootFormBuilderOptions , $ filterFormBuilderOptions ) ; if ...
Creates a filtration named form .
13,905
public function index ( $ trashed = false ) { $ this -> authorize ( UsersPolicy :: PERMISSION_LIST ) ; $ users = $ this -> user -> with ( 'roles' ) -> protectAdmins ( ) -> when ( $ trashed , function ( $ query ) { return $ query -> onlyTrashed ( ) ; } ) -> paginate ( 30 ) ; $ title = trans ( 'auth::users.titles.users-l...
List the users .
13,906
public function listByRole ( Role $ role , $ trashed = false ) { $ this -> authorize ( UsersPolicy :: PERMISSION_LIST ) ; $ users = $ role -> users ( ) -> with ( 'roles' ) -> protectAdmins ( ) -> paginate ( 30 ) ; $ title = trans ( 'auth::users.titles.users-list' ) . " - {$role->name} Role" . ( $ trashed ? ' - ' . tran...
List the users by a role .
13,907
public function create ( Role $ role ) { $ this -> authorize ( UsersPolicy :: PERMISSION_CREATE ) ; $ roles = $ role -> all ( ) ; $ this -> setTitle ( $ title = trans ( 'auth::users.titles.create-user' ) ) ; $ this -> addBreadcrumb ( $ title ) ; return $ this -> view ( 'admin.users.create' , compact ( 'roles' ) ) ; }
Show the create a new user form .
13,908
public function store ( CreateUserRequest $ request , User $ user ) { $ this -> authorize ( UsersPolicy :: PERMISSION_CREATE ) ; $ user -> fill ( $ request -> getValidatedData ( ) ) ; $ user -> is_active = true ; $ user -> save ( ) ; $ user -> roles ( ) -> sync ( $ request -> get ( 'roles' ) ) ; $ this -> transNotifica...
Store the new user .
13,909
public function show ( User $ user ) { $ this -> authorize ( UsersPolicy :: PERMISSION_SHOW ) ; $ user -> load ( [ 'roles' , 'roles.permissions' ] ) ; $ this -> setTitle ( $ title = trans ( 'auth::users.titles.user-details' ) ) ; $ this -> addBreadcrumb ( $ title ) ; return $ this -> view ( 'admin.users.show' , compact...
Show the user s details .
13,910
public function edit ( User $ user , Role $ role ) { $ this -> authorize ( UsersPolicy :: PERMISSION_UPDATE ) ; $ user -> load ( [ 'roles' , 'roles.permissions' ] ) ; $ roles = $ role -> all ( ) ; $ this -> setTitle ( $ title = trans ( 'auth::users.titles.edit-user' ) ) ; $ this -> addBreadcrumb ( $ title ) ; return $ ...
Show the edit the user form .
13,911
public function restore ( User $ user ) { $ this -> authorize ( UsersPolicy :: PERMISSION_UPDATE ) ; try { $ user -> restore ( ) ; $ message = $ this -> transNotification ( 'restored' , [ 'name' => $ user -> full_name ] , $ user -> toArray ( ) ) ; return $ this -> jsonResponseSuccess ( compact ( 'message' ) ) ; } catch...
Restore the trashed user .
13,912
public function impersonate ( User $ user , Impersonator $ impersonator ) { if ( ! $ impersonator -> start ( auth ( ) -> user ( ) , $ user ) ) { $ this -> notifyDanger ( trans ( 'auth::users.messages.impersonation-failed.message' ) , trans ( 'auth::users.messages.impersonation-failed.title' ) ) ; return redirect ( ) ->...
Impersonate a user .
13,913
private function getEnum ( ) { $ enumResult = $ this -> db -> query ( new Raw ( <<<SQL SELECT t.typname as name, n.nspname as schema, array_agg( e.enumlabel ORDER BY e.enumsortorder ) as labels FROM pg_enum e ...
Get array of enum s and their values from the database
13,914
public static function exists ( $ type = 'post' ) { switch ( $ type ) { case 'post' : return ( ! empty ( $ _POST ) ) ? true : false ; break ; case 'get' : return ( ! empty ( $ _GET ) ) ? true : false ; break ; default : return false ; break ; } }
Check the given request type exists .
13,915
public static function get ( $ item ) { if ( isset ( $ _POST [ $ item ] ) ) { return $ _POST [ $ item ] ; } elseif ( isset ( $ _GET [ $ item ] ) ) { return $ _GET [ $ item ] ; } else { return '' ; } }
Returns the given input item .
13,916
public function buildForm ( FormBuilderInterface $ builder , array $ options ) { global $ kernel ; $ modules = array ( ) ; $ dir = $ kernel -> getRootDir ( ) . '/../src/Terrific/Module/' ; $ finder = new Finder ( ) ; $ finder -> directories ( ) -> in ( $ dir ) -> depth ( '== 0' ) ; foreach ( $ finder as $ file ) { $ fi...
Builds the Skin form .
13,917
public function addOption ( $ opt , $ type ) { if ( $ type !== self :: OPT_PARAM || $ type !== self :: OPT_SWITCH ) { return ; } $ this -> options [ ( string ) $ opt ] = $ type ; }
Adds an option to the argument parser .
13,918
public function parse ( ) { global $ argv ; $ options = array ( ) ; $ parameters = array ( ) ; $ argc = count ( $ argv ) ; $ paramCount = count ( $ this -> parameters ) ; if ( $ argc - 1 < $ paramCount ) { throw new \ Exception ( "The command requires $paramCount parameters." ) ; } for ( $ i = $ paramCount - 1 ; $ i >=...
Parses the parameters and throws an error if the user supplied an invalid format .
13,919
public function exchangeArray ( $ data ) { foreach ( $ data as $ prop => $ value ) { $ methodName = 'set' . ucfirst ( $ prop ) ; if ( method_exists ( $ this , $ methodName ) ) { call_user_func ( array ( $ this , $ methodName ) , $ value ) ; } } }
Exchange array - used in ZF2 form
13,920
public function delete ( $ idOrDocument ) { $ cache = $ this -> getServiceLocator ( ) -> get ( 'ClassifiedCache' ) ; $ main = $ this -> getServiceLocator ( ) -> get ( 'neobazaar.service.main' ) ; $ classifiedService = $ this -> getServiceLocator ( ) -> get ( 'document.service.classified' ) ; $ entityManager = $ main ->...
Delete an image document and related images . If there is a parent delete its cache .
13,921
public function connect ( ) : DatabaseConnection { if ( null !== $ this -> pdo ) { return $ this ; } try { $ pdoCreator = $ this -> getPdoCreator ( ) ; $ this -> pdo = $ pdoCreator ( $ this -> configuration ) ; $ this -> pdo -> setAttribute ( PDO :: ATTR_ERRMODE , PDO :: ERRMODE_EXCEPTION ) ; $ this -> pdo -> setAttrib...
establishes the connection
13,922
public function prepare ( string $ statement , array $ driverOptions = [ ] ) : Statement { if ( null === $ this -> pdo ) { $ this -> connect ( ) ; } try { return new PdoStatement ( $ this -> pdo -> prepare ( $ statement , $ driverOptions ) ) ; } catch ( PDOException $ pdoe ) { throw new DatabaseException ( $ pdoe -> ge...
creates a prepared statement
13,923
public function query ( string $ sql , array $ driverOptions = [ ] ) : QueryResult { if ( null === $ this -> pdo ) { $ this -> connect ( ) ; } try { if ( ! isset ( $ driverOptions [ 'fetchMode' ] ) ) { return new PdoQueryResult ( $ this -> pdo -> query ( $ sql ) ) ; } switch ( $ driverOptions [ 'fetchMode' ] ) { case P...
executes a SQL statement
13,924
public function exec ( string $ statement ) : int { if ( null === $ this -> pdo ) { $ this -> connect ( ) ; } try { return $ this -> pdo -> exec ( $ statement ) ; } catch ( PDOException $ pdoe ) { throw new DatabaseException ( $ pdoe -> getMessage ( ) , $ pdoe ) ; } }
execute an SQL statement and return the number of affected rows
13,925
public function getLastInsertId ( string $ name = null ) { if ( null === $ this -> pdo ) { throw new DatabaseException ( 'Not connected: can not retrieve last insert id' ) ; } try { return $ this -> pdo -> lastInsertId ( $ name ) ; } catch ( PDOException $ pdoe ) { throw new DatabaseException ( $ pdoe -> getMessage ( )...
returns the last insert id
13,926
public function get ( $ name = 'HTTP_HOST' ) { $ name = isset ( $ this -> references [ $ name ] ) ? $ this -> references [ $ name ] : $ this -> resolveCase ( $ name ) ; return $ this -> has ( $ name ) ? $ _SERVER [ $ name ] : false ; }
get the variable in server
13,927
public static function rmtree ( string $ path ) { $ path = self :: realpath ( $ path ) ; if ( empty ( $ path ) ) return true ; if ( empty ( self :: $ required_prefix ) ) throw new \ RuntimeException ( "Safety measure: required prefix needs to be set before running rmtree" ) ; if ( strpos ( $ path , self :: $ required_p...
Delete a directory and its contents . The provided path must be inside the configured prefix .
13,928
public static function getPermissions ( $ path ) { try { $ mode = @ fileperms ( $ path ) ; if ( $ mode === false ) throw new IOException ( ) ; } catch ( Throwable $ e ) { throw new IOException ( "Could not stat: " . $ path ) ; } $ perms = array ( 'owner' => array ( 'read' => ( bool ) ( $ mode & 0x0100 ) , 'write' => ( ...
Return the permissions set on the specified file .
13,929
public static function compileMode ( array $ perms ) { $ fmode = 0 ; $ fmode |= ! empty ( $ perms [ 'owner' ] [ 'read' ] ) ? self :: OWNER_READ : 0 ; $ fmode |= ! empty ( $ perms [ 'owner' ] [ 'write' ] ) ? self :: OWNER_WRITE : 0 ; $ fmode |= ! empty ( $ perms [ 'owner' ] [ 'execute' ] ) ? self :: OWNER_EXECUTE : 0 ; ...
Create a file mode from an array containing permissions . The array can have owner group and world members each which can have read write and execute booleans that indicate whether that permission is present or not .
13,930
protected function menu ( ) { $ this -> Benchmark -> start ( 'getMenu' ) ; try { $ menu = $ this -> CMSNavItemService -> getMenu ( ) ; } catch ( Exception $ e ) { return '' ; } $ this -> Benchmark -> end ( 'getMenu' ) ; $ this -> Benchmark -> start ( 'buildMenu' ) ; $ dom_id = $ this -> getParameter ( 'id' ) ; $ dom_cl...
Returns a full HTML rendering of the CMS navigation menu
13,931
protected function lookupElementsForNav ( $ element_or_aspect ) { $ results = array ( ) ; if ( substr ( $ element_or_aspect , 0 , 1 ) == '@' ) { $ elements = $ this -> ElementService -> findAllWithAspect ( substr ( $ element_or_aspect , 1 ) ) ; foreach ( $ elements as $ element ) { $ results [ ] = array ( 'Name' => $ e...
REturns all the elements for the specified element or aspect
13,932
public function sortingLink ( ) { $ filterlist = '' ; if ( $ this -> getParameter ( 'filter' ) != null ) { foreach ( $ this -> getParameter ( 'filter' ) as $ get => $ value ) { $ filterlist .= 'filter[' . $ get . '][]=' . $ value . '&' ; } } if ( $ this -> getParameter ( 'sort' ) != null ) { $ sort = $ this -> getParam...
Returns a URL with sort parameters
13,933
private function authenticateMenuEntries ( Menu $ menu , array $ userRoles ) { foreach ( $ menu -> getEntries ( ) as $ e ) { if ( ! $ e -> getAuth ( ) ) { $ e -> setAttribute ( 'display' , NULL ) ; } else { $ e -> setAttribute ( 'display' , 'none' ) ; foreach ( $ userRoles as $ role ) { if ( $ e -> isAuthenticatedByRol...
authenticate menu entries by checking each one against the user s roles if necessary
13,934
public function offsetGet ( $ key ) { if ( isset ( $ this -> granules [ $ key ] ) ) { return $ this -> granules [ $ key ] ; } throw new \ OutOfBoundsException ( sprintf ( 'Granule "%s" is not defined.' , $ key ) ) ; }
Returns a granule .
13,935
public function getLinkQuery ( $ specific = true ) { $ query = $ this -> getDB ( ) -> newSelect ( ) ; $ query -> from ( $ this -> getTable ( ) ) ; if ( $ specific ) { $ query = $ this -> populateQuerySpecific ( $ query ) ; } return $ query ; }
Simple select query from the link table
13,936
public function index ( Request $ request ) { $ spammers = $ this -> paginate ( $ this -> blocker -> all ( ) , $ request , $ this -> perPage ) ; $ this -> setTitle ( $ title = trans ( 'seo::spammers.titles.spammers-list' ) ) ; $ this -> addBreadcrumb ( $ title ) ; return $ this -> view ( 'admin.spammers.index' , compac...
List all the spammers .
13,937
public function join ( $ join = [ ] ) { $ this -> string [ 'join' ] = $ this -> useBuilder ( 'join' ) -> join ( $ join , $ this -> getBase ( ) -> getTable ( ) ) ; return $ this ; }
Join komutu ekler
13,938
public function collect ( Request $ request , Response $ response , Exception $ exception = null ) { $ objects = array ( ) ; $ objectNames = $ this -> flexModel -> getObjectNames ( ) ; foreach ( $ objectNames as $ objectName ) { $ fieldNames = $ this -> flexModel -> getFieldNames ( $ objectName ) ; $ objects [ ] = arra...
Collect the specific FlexModel data for the Symfony Profiler .
13,939
public static function getManager ( ManagerRegistry $ or , $ class ) { $ manager = $ or -> getManagerForClass ( $ class ) ; if ( null === $ manager ) { foreach ( $ or -> getManagers ( ) as $ objectManager ) { if ( $ objectManager -> getMetadataFactory ( ) -> hasMetadataFor ( $ class ) && self :: isValidManager ( $ obje...
Get the doctrine object manager of the class .
13,940
private static function isValidManager ( ObjectManager $ manager , $ class ) { $ meta = $ manager -> getClassMetadata ( $ class ) ; return ! $ meta instanceof OrmClassMetadata || ! $ meta -> isMappedSuperclass ; }
Check if the object manager is valid .
13,941
protected function extractFieldValues ( ArrayAccess $ item , WriterFieldInterface ... $ fields ) : array { return array_map ( function ( WriterFieldInterface $ field ) use ( $ item ) : string { return $ field -> getValue ( $ item ) ; } , $ fields ) ; }
Extract item values from fields .
13,942
public function getEvent ( $ name ) { if ( ! isset ( $ this -> _events ) ) $ this -> _events = [ ] ; if ( ! isset ( $ this -> _events [ $ name ] ) ) { $ className = $ this -> getEventClassName ( ) ; $ this -> _events [ $ name ] = new $ className ( $ name ) ; } return $ this -> _events [ $ name ] ; }
Returns an event by name . If the event doesnt exist yet it is created
13,943
protected function checkParameters ( $ parameters , $ requirements = true ) { if ( is_array ( $ parameters ) ) { $ parameters = array_replace ( $ this -> getParameters ( ) , $ parameters ) ; } $ obstacles = $ this -> collectRenderingObstacles ( $ parameters , $ requirements ) ; if ( $ obstacles ) { throw new WidgetInva...
Merges provided parameters with those from objects and checks them
13,944
protected function collectRenderingObstacles ( $ parameters , $ requirements = true ) { if ( ! is_array ( $ parameters ) ) { return [ 'Parameters should be an array' ] ; } if ( true === $ requirements ) { $ requirements = $ this -> getRequiredParameters ( ) ; } $ obstacles = [ ] ; foreach ( $ requirements as $ required...
Returns an array of possible problems for rendering widget or of some widget rendering functionality
13,945
public function format ( \ DateTimeInterface $ date ) { if ( $ date -> getOffset ( ) == 0 ) { return $ date -> format ( 'YmdHis\Z' ) ; } return str_replace ( ':' , '\'' , $ date -> format ( 'YmdHisP' ) ) . '\'' ; }
Formats the date according to the formatting string
13,946
public function getDomXpath ( $ url ) { $ dom = $ this -> getDomDocument ( $ url ) ; $ xpath = new \ DOMXPath ( $ dom ) ; return $ xpath ; }
Get the DOMXPath of the downloaded content
13,947
public function getAll ( Request $ request ) { $ this -> authorize ( MediasPolicy :: PERMISSION_LIST ) ; return $ this -> jsonResponseSuccess ( [ 'medias' => $ this -> media -> all ( $ request -> get ( 'location' , '/' ) ) , ] ) ; }
Get the the media files .
13,948
private function getDestinations ( $ name , $ location ) { $ selected = ( $ isHome = $ location === '/' ) ? $ name : "{$location}/{$name}" ; $ destinations = $ this -> media -> directories ( $ location ) -> pluck ( 'path' ) -> reject ( function ( $ path ) use ( $ selected ) { return $ path === $ selected ; } ) -> value...
Get the destinations paths .
13,949
private function performMoveMedia ( $ type , $ location , $ oldName , $ newName ) { $ from = "{$location}/{$oldName}" ; switch ( Str :: lower ( $ type ) ) { case Media :: MEDIA_TYPE_FILE : return $ this -> moveFile ( $ from , $ location , $ newName ) ; case Media :: MEDIA_TYPE_DIRECTORY : return $ this -> moveDirectory...
Perform the media movement .
13,950
private function moveDirectory ( $ from , $ location , $ newName ) { $ newName = Str :: slug ( $ newName ) ; return tap ( "{$location}/{$newName}" , function ( $ to ) use ( $ from ) { $ this -> media -> move ( $ from , $ to ) ; } ) ; }
Move directory .
13,951
private function performDeleteMedia ( $ type , $ path ) { switch ( Str :: lower ( $ type ) ) { case Media :: MEDIA_TYPE_FILE : return $ this -> media -> deleteFile ( $ path ) ; case Media :: MEDIA_TYPE_DIRECTORY : return $ this -> media -> deleteDirectory ( trim ( $ path , '/' ) ) ; default : return false ; } }
Perform the media deletion .
13,952
public function register ( App $ app ) { $ app [ "logger.service" ] = $ app -> protect ( function ( string $ loggerName = "" ) use ( $ app ) { $ cacheName = "logger.service-{$loggerName}" ; if ( isset ( $ app [ $ cacheName ] ) ) { return $ app [ $ cacheName ] ; } if ( isset ( $ app [ "config.service" ] ) === false || g...
Register Logger Service Provider
13,953
public function setName ( string $ name ) { $ this -> name = $ name ; while ( preg_match ( '/^(.*)\[([^\]]*)\]$/' , $ name , $ matches ) === 1 ) { if ( empty ( $ matches [ 2 ] ) ) { if ( $ this -> name_depth > 1 ) throw new \ InvalidArgumentException ( "Invalid name: {$this->name}" ) ; $ this -> is_array = true ; } els...
Change the name of the field .
13,954
public function addValidator ( $ validator ) { if ( $ validator === FormField :: TYPE_FILE ) { $ this -> is_file = true ; $ validator = Type :: RESOURCE ; } if ( ! $ validator instanceof Validator ) { $ validator = new Validator ( $ validator , [ 'unstrict' => true ] ) ; } $ this -> validators [ ] = $ validator ; retur...
Change the type of the field
13,955
public function removeValidator ( int $ index ) { $ validators = $ this -> validators ; unset ( $ validators [ $ index ] ) ; $ this -> validators = array_values ( $ validators ) ; return $ this ; }
Remove a validator with a specific index
13,956
public function getErrors ( ) { if ( ! empty ( $ this -> fixed_error ) ) return count ( $ this -> errors ) ? [ $ this -> fixed_error ] : [ ] ; return $ this -> errors ; }
Return the error messages produced during validation . Should be called after validation failed otherwise an non - relevant or empty array will be returned .
13,957
public function setError ( array $ msg ) { if ( ! isset ( $ msg [ 'msg' ] ) ) throw new InvalidArgumentException ( "Error message does not contain msg key" ) ; $ this -> errors = [ $ msg ] ; $ this -> fixed_error = $ msg ; return $ this ; }
Set the form field with an error state . This will override the fixed error .
13,958
public function getValue ( bool $ transform = false ) { if ( $ transform && $ this -> transformer !== null ) return $ this -> transformer -> serialize ( $ this -> value ) ; return $ this -> value ; }
Returns the value optionally HTML escaped
13,959
public function setValue ( $ value , bool $ transform = false ) { if ( null === $ value ) $ this -> value = null ; elseif ( $ transform && $ this -> transformer !== null ) $ this -> value = $ this -> transformer -> deserialize ( $ value ) ; else $ this -> value = $ value ; return $ this ; }
Change the value for this field . The value is not validated this is just to be referred to later for example for showing to the visitor
13,960
public static function formatErrorMessage ( array $ error_message ) { $ msg = $ error_message [ 'msg' ] ?? "" ; $ context = $ error_message [ 'context' ] ?? [ ] ; if ( class_exists ( "Wedeto\I18n\I18nShortcut" ) ) { return t ( $ msg , $ context ) ; } return WF :: fillPlaceholders ( $ msg , $ context ) ; }
Format the error message into a single string
13,961
public function registerObject ( $ serviceName , $ instance ) { if ( ! is_string ( $ serviceName ) ) { throw new InvalidParameterTypeException ( "Expected a string" ) ; } if ( isset ( $ this -> aliases [ $ serviceName ] ) ) { throw new ServiceAliasMismatchException ( $ serviceName ) ; } unset ( $ this -> singletons [ $...
If you are not running PHPUnit or for that matter any other testing environment then you are not suppose to use this function .
13,962
public function saveJsonString ( $ property , $ jsonString ) { $ this -> jsonManager ( ) -> isJsonProperty ( $ property , true ) ; $ this -> { $ property } = $ jsonString ; }
Set the raw json string on the model
13,963
private function jsonManager ( ) { if ( $ this -> jsonManager === null ) $ this -> jsonManager = new JsonManager ( $ this , $ this -> jsonProperty ) ; return $ this -> jsonManager ; }
Get the JsonManager instance
13,964
private function createImageFolder ( ) { $ em = $ this -> container -> get ( 'ekyna_payment.method.manager' ) ; $ folderRepository = $ this -> container -> get ( 'ekyna_media.folder.repository' ) ; if ( null === $ rootFolder = $ folderRepository -> findRoot ( ) ) { throw new \ RuntimeException ( 'Can\'t find root folde...
Creates the payment images folder .
13,965
public function getMakefiles ( $ dir ) { $ finder = new Finder ( ) ; $ finder -> in ( $ dir ) -> files ( ) -> depth ( '< 1' ) -> name ( '*.make*' ) ; return $ finder ; }
Return Finder with all makefiles in directory .
13,966
public function source ( $ dir ) { foreach ( $ this -> getMakefiles ( $ dir ) as $ file ) { $ f = fopen ( $ file , 'r' ) ; $ peek = fread ( $ f , 1000 ) ; fclose ( $ f ) ; if ( strpos ( $ peek , 'api' ) !== FALSE && strpos ( $ peek , 'core' ) !== FALSE ) { return true ; } } return false ; }
Checks if Drupal project but source .
13,967
public function contain ( string $ id ) : bool { if ( $ this -> properties ( ) -> containSection ( $ id ) ) { return true ; } return $ this -> hasFallback ( ) ; }
checks whether database configuration for given id exists
13,968
public function get ( string $ id ) { if ( ! $ this -> properties ( ) -> containSection ( $ id ) ) { if ( ! $ this -> hasFallback ( ) ) { throw new \ OutOfBoundsException ( 'No database configuration known for database requested with id ' . $ id ) ; } $ id = DatabaseConfiguration :: DEFAULT_ID ; } if ( ! $ this -> prop...
returns database configuration with given id
13,969
protected function properties ( ) : Properties { if ( null === $ this -> dbProperties ) { $ this -> dbProperties = Properties :: fromFile ( $ this -> configPath . '/' . $ this -> descriptor . '.ini' ) ; } return $ this -> dbProperties ; }
reads properties if not done yet
13,970
public static function RemoveWorkingDir ( string $ path = null ) : string { if ( \ is_null ( $ path ) ) { return '' ; } $ wd = '~^' . \ preg_quote ( static :: Unixize ( \ getcwd ( ) ) . '/' ) . '~' ; return \ preg_replace ( $ wd , '' , static :: Unixize ( $ path ) ) ; }
Removes the current working directory from defined path if it starts with it .
13,971
public function handlePHPError ( $ error_number , $ error , $ error_file , $ error_line ) { if ( ( error_reporting ( ) & $ error_number ) === 0 ) return ; throw new PHPException ( $ error_number , $ error , $ error_file , $ error_line ) ; }
Catches all the PHP errors and convert them into a PHP exception
13,972
public function handleException ( \ Exception $ e ) { $ environment = $ this -> core -> getCurrentDomain ( ) -> environment ; if ( isset ( $ this -> core -> getSettings ( ) -> errorhandling -> controller -> $ environment ) === true ) { $ controller = FrameworkUtils :: stringToClassName ( $ this -> core -> getSettings (...
Default stub for print an exception
13,973
private function maxLength ( ) { $ max = mb_strlen ( $ this -> value ) ; if ( ! $ ret = $ max <= $ this -> options -> max ) { $ this -> error ( 1 ) ; } return $ ret ; }
Check max length
13,974
private function minLength ( ) { $ min = mb_strlen ( $ this -> value ) ; if ( ! $ ret = $ min >= $ this -> options -> min ) { $ this -> error ( 2 ) ; } return $ ret ; }
Check min length
13,975
protected function determineArgumentsFor ( ReflectionMethod $ method , string $ class , string $ method_name , array $ args , string $ selector , Injector $ injector ) { $ params = $ method -> getParameters ( ) ; $ method_args = [ ] ; $ used_optional = false ; foreach ( $ params as $ param ) { $ name = $ param -> getNa...
Find arguments for a method
13,976
public function getValues ( $ name ) { if ( ! isset ( $ this -> enums [ $ name ] ) ) { throw new UnknownEnumException ( $ name ) ; } return $ this -> enums [ $ name ] ; }
Public accessor for enum options
13,977
public function isValid ( $ name , $ value = null ) { if ( ! isset ( $ this -> enums [ $ name ] ) ) { return false ; } elseif ( $ value === null ) { return true ; } return ! isset ( $ value ) || in_array ( $ value , $ this -> enums [ $ name ] ) ; }
Is valid check
13,978
public function getRandomValue ( $ name ) { if ( ! isset ( $ this -> enums [ $ name ] ) ) { throw new UnknownEnumException ( $ name ) ; } return $ this -> enums [ $ name ] [ array_rand ( $ this -> enums [ $ name ] ) ] ; }
Get a random value from a enum . Primarily used by the import script
13,979
private function writeStatus ( ) { $ string = $ this -> response -> getProtocolVersion ( ) . ' ' . $ this -> response -> getStatusCode ( ) . ' ' . $ this -> response -> getReasonPhrase ( ) ; header ( $ string , true , $ this -> response -> getStatusCode ( ) ) ; }
Write response status
13,980
private function writeHeaders ( ) { $ headers = $ this -> response -> getHeaders ( ) ; foreach ( $ headers as $ name => $ list ) { header ( "$name: " . implode ( ', ' , $ list ) ) ; } }
Write headers .
13,981
public static function get ( string $ key ) { return isset ( Notification :: $ notifications [ $ key ] ) ? Notification :: $ notifications [ $ key ] : null ; }
Returns a specific variable from the Notifications array .
13,982
public static function set ( string $ key , $ value ) : void { $ _SESSION [ Notification :: SESSION_KEY ] [ $ key ] = $ value ; }
Adds specific variable to the Notifications array .
13,983
public static function init ( ) : void { if ( ! empty ( $ _SESSION [ Notification :: SESSION_KEY ] ) && is_array ( $ _SESSION [ Notification :: SESSION_KEY ] ) ) { Notification :: $ notifications = $ _SESSION [ Notification :: SESSION_KEY ] ; } $ _SESSION [ Notification :: SESSION_KEY ] = [ ] ; }
Initializes the Notification service .
13,984
public function getString ( $ row , Table $ table ) { if ( ! $ this -> isVisible ( $ row ) ) { return "" ; } $ options = $ this -> htmlOptions ; if ( $ this -> title != "" ) { eval ( "\$options['title'] = {$this->title};" ) ; } elseif ( ! isset ( $ options [ 'title' ] ) ) { $ options [ 'title' ] = '' ; } if ( $ this ->...
Final result a HTML Element for current action ;
13,985
public function getIcon ( $ title , Table $ table ) { if ( $ this -> icon ) { $ icon = str_replace ( array ( '%DATATABLE_ASSETS%' , '%SIZE%' ) , array ( $ table -> getAssetsURL ( ) , $ this -> iconSize . 'x' . $ this -> iconSize ) , $ this -> icon ) ; if ( '%MPF_ASSETS%' == substr ( $ icon , 0 , 12 ) ) { $ icon = Asset...
Get HTML img tag for icon or an empty string if there is no icon
13,986
public function isVisible ( $ row ) { if ( false === $ this -> visible ) return false ; elseif ( is_string ( $ this -> visible ) ) { $ visible = true ; eval ( "\$visible = {$this->visible};" ) ; if ( false == $ visible ) return false ; } return true ; }
Checks if action is visible or not
13,987
public function allTransactions ( int $ id ) { if ( ! $ object = $ this -> repository -> find ( $ id ) ) { abort ( 404 ) ; } $ transactions = $ object -> getLatestTransactions ( ) ; return TransactionResource :: collection ( $ transactions ) ; }
Get latest Transactions
13,988
function LinesToArray ( $ text ) { $ result = array ( ) ; $ lines = Str :: SplitLines ( $ text ) ; foreach ( $ lines as $ line ) { $ line = trim ( $ line ) ; if ( ! $ line ) { continue ; } $ pos = strpos ( $ line , $ this -> separator ) ; $ key = $ line ; $ value = '' ; if ( $ pos !== false ) { $ key = substr ( $ line ...
Fetches the lines of a text and serializes them to an array of key value pairs
13,989
public function searchAction ( Request $ request ) { $ moduleManager = $ this -> get ( 'terrific.composer.module.manager' ) ; $ modules = $ moduleManager -> getModules ( ) ; $ pageManager = $ this -> get ( 'terrific.composer.page.manager' ) ; $ pages = $ pageManager -> getPages ( ) ; $ results = array_merge ( $ modules...
Displays the terrific component search .
13,990
private function getClass ( $ key ) { if ( ! array_key_exists ( $ key , $ this -> config [ 'classes' ] ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Undefined resource class "%s".' , $ key ) ) ; } return $ this -> config [ 'classes' ] [ $ key ] ; }
Returns the class for the given key .
13,991
public static function shorten ( $ text , $ maxlength = 140 , $ end = '[...]' ) { $ maxlength ++ ; if ( mb_strlen ( $ text ) > $ maxlength ) { $ subex = mb_substr ( $ text , 0 , $ maxlength - 5 ) ; $ exwords = explode ( ' ' , $ subex ) ; $ excut = - ( mb_strlen ( $ exwords [ count ( $ exwords ) - 1 ] ) ) ; if ( $ excut...
Builds an excerpt from a longer text .
13,992
function get_nav_menu_item_children ( $ parent_id , $ nav_menu_items , $ depth = true ) { $ nav_menu_item_list = array ( ) ; foreach ( ( array ) $ nav_menu_items as $ nav_menu_item ) { if ( $ nav_menu_item -> menu_item_parent == $ parent_id ) { $ nav_menu_item_list [ ] = $ nav_menu_item ; if ( $ depth ) { if ( $ childr...
Returns all child nav_menu_items under a specific parent
13,993
public static function posted_on ( ) { return sprintf ( __ ( '<span class="sep">Posted on </span><a href="%1$s" title="%2$s" rel="bookmark"><time class="entry-date" datetime="%3$s" pubdate>%4$s</time></a><span class="by-author"> <span class="sep"> by </span> <span class="author vcard"><a class="url fn n" href="%5$s" ti...
The Posted by Derp in FooBar post - meta . Taken from TwentyEleven Wordpress Theme .
13,994
public static function get_title ( ) { global $ page , $ paged ; $ r = wp_title ( '|' , false , 'right' ) ; $ r .= get_bloginfo ( 'name' ) ; $ site_description = get_bloginfo ( 'description' , 'display' ) ; if ( $ site_description && ( is_home ( ) || is_front_page ( ) ) ) { $ r .= " | $site_description" ; } if ( $ page...
A Standard title for Wordpress Pages . Taken from TwentyEleven Wordpress Theme .
13,995
public static function instance ( $ reload = false ) { if ( HttpRequest :: $ instance == null || $ reload ) { HttpRequest :: $ instance = new HttpRequest ( ) ; } return HttpRequest :: $ instance ; }
Enforce a singleton session object
13,996
protected function _advanceTracker ( $ tracker ) { if ( ! ( $ tracker instanceof Iterator ) ) { throw $ this -> _createInvalidArgumentException ( $ this -> __ ( 'Can only advance an Iterator tracker' ) , null , null , $ tracker ) ; } $ tracker -> next ( ) ; }
Advances the iterator forward .
13,997
protected function _resetTracker ( $ tracker ) { if ( ! ( $ tracker instanceof Iterator ) ) { throw $ this -> _createInvalidArgumentException ( $ this -> __ ( 'Can only reset an Iterator tracker' ) , null , null , $ tracker ) ; } $ tracker -> rewind ( ) ; }
Reset the iterator back to the start .
13,998
protected function _createIterationFromTracker ( $ tracker ) { if ( ! ( $ tracker instanceof Iterator ) ) { throw $ this -> _createInvalidArgumentException ( $ this -> __ ( 'Can only create an iteration from an Iterator tracker' ) , null , null , $ tracker ) ; } $ key = $ this -> _calculateKey ( $ tracker ) ; $ value =...
Creates a new iteration using an internal iterator .
13,999
static public function sortByKeyRecursive ( array $ array ) { ksort ( $ array ) ; foreach ( $ array as $ key => $ value ) { if ( is_array ( $ value ) && ! empty ( $ value ) ) { $ array [ $ key ] = self :: sortByKeyRecursive ( $ value ) ; } } return $ array ; }
Sorts an array recursively by key