idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
22,200 | public function format ( ) { $ json = ( string ) $ this -> getParameter ( 'value' ) ; if ( empty ( $ json ) ) { return '""' ; } $ html = ( boolean ) $ this -> getParameter ( 'html' ) ; return JSONUtils :: format ( $ json , $ html ) ; } | Indents a flat JSON string to make it more human - readable |
22,201 | public static function gauge ( $ val , $ floor = 0 ) { $ colors = self :: getGaugeColors ( ) ; $ key_size = 100 / count ( $ colors ) ; $ key = floor ( $ val / $ key_size ) ; return ( array_key_exists ( ( int ) $ key , $ colors ) ) ? $ colors [ $ key ] : end ( $ colors ) ; } | Turn a val to a color for a gauge |
22,202 | public static function hexToRgb ( $ hex ) { $ hex = preg_replace ( '/[^a-zA-Z0-9]/' , '' , $ hex ) ; if ( strlen ( $ hex ) === 3 ) { $ hex = preg_replace ( '/([a-f0-9])/i' , "$1$1" , $ hex ) ; } return array_combine ( array ( 'r' , 'g' , 'b' ) , array_map ( 'hexdec' , str_split ( $ hex , 2 ) ) ) ; } | Convert hex to RGB values |
22,203 | public static function colorToHex ( $ color ) { $ colors = array ( 'maroon' => '800000' , 'red' => 'FF0000' , 'orange' => 'FFA500' , 'yellow' => 'FFFF00' , 'olive' => '808000' , 'purple' => '800080' , 'fuchsia' => 'FF00FF' , 'white' => 'FFFFFF' , 'lime' => '00FF00' , 'green' => '008000' , 'navy' => '000080' , 'blue' => '0000FF' , 'aqua' => '00FFFF' , 'teal' => '008080' , 'black' => '000000' , 'silver' => 'C0C0C0' , 'gray' => '808080' , ) ; if ( array_key_exists ( $ color , $ colors ) ) { return $ colors [ $ color ] ; } $ color_pattern = '/rgb\((.*?)\)/' ; preg_match ( $ color_pattern , $ color , $ matches ) ; if ( is_array ( $ matches ) && count ( $ matches ) > 0 ) { $ rgb = explode ( ',' , $ matches [ 1 ] ) ; if ( is_array ( $ rgb ) && count ( $ rgb ) === 3 ) { return self :: RGBToHex ( $ rgb [ 0 ] , $ rgb [ 1 ] , $ rgb [ 2 ] ) ; } } return $ color ; } | Convert color name to hex |
22,204 | public static function Ut1tt ( $ ut11 , $ ut12 , $ dt , & $ tt1 , & $ tt2 ) { $ dtd ; $ dtd = $ dt / DAYSEC ; if ( $ ut11 > $ ut12 ) { $ tt1 = $ ut11 ; $ tt2 = $ ut12 + $ dtd ; } else { $ tt1 = $ ut11 + $ dtd ; $ tt2 = $ ut12 ; } return 0 ; } | - - - - - - - - - i a u U t 1 t t - - - - - - - - - |
22,205 | public function getAllRootIds ( ) { $ entityClass = $ this -> getEntityClass ( ) ; $ query = $ this -> getObjectManager ( ) -> createQuery ( 'SELECT DISTINCT c.root FROM ' . $ entityClass . ' c' ) ; $ result = $ query -> getResult ( ) ; $ rootIds = array ( ) ; foreach ( $ result as $ resultArray ) { $ rootIds [ ] = $ resultArray [ 'root' ] ; } return $ rootIds ; } | Returns a list of all root category ids |
22,206 | public function findOneByName ( $ name ) { $ entityClass = $ this -> getEntityClass ( ) ; return $ this -> getObjectManager ( ) -> getRepository ( $ entityClass ) -> findOneByName ( $ name ) ; } | Find one category by it s name |
22,207 | public function findOneByTitle ( $ title ) { $ entityClass = $ this -> getEntityClass ( ) ; return $ this -> getObjectManager ( ) -> getRepository ( $ entityClass ) -> findOneByTitle ( $ title ) ; } | Find one category by it s title |
22,208 | public static function connect ( $ host = null , $ database = null , $ user = null , $ password = null ) { if ( config ( 'app.setup' ) ) { self :: $ connection = new MysqlConnector ( $ host , $ database , $ user , $ password ) ; self :: $ server = self :: $ connection -> connector ; } return self :: $ server ; } | Connect to Mysql database server . |
22,209 | public function getColmuns ( $ table ) { $ table = self :: table ( $ table ) ; $ columns = [ ] ; $ data = Database :: read ( "select COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = '" . Config :: get ( 'database.database' ) . "' AND TABLE_NAME = '$table';" ) ; foreach ( $ data as $ key => $ value ) { $ columns [ ] = $ value [ 'COLUMN_NAME' ] ; } return $ columns ; } | Get columns of data table . |
22,210 | public function getNormalColumn ( $ table ) { $ all = self :: getColmuns ( $ table ) ; $ incs = self :: getIncrement ( $ table ) ; return Collection :: except ( $ incs , $ all ) ; } | Get columns of data table without auto increment columns . |
22,211 | public function endpoint_callback ( \ WP_REST_Request $ request ) { $ params = $ request -> get_params ( ) ; $ id = $ params [ 'id' ] ; $ slug = false === $ params [ 'slug' ] ? false : trim ( $ params [ 'slug' ] , '/' ) ; if ( false === $ id && false === $ slug ) { return new \ WP_Error ( self :: INVALID_PARAMS , 'The request must have either an id or a slug' , [ 'status' => 400 ] ) ; } $ query_args = [ 'post_type' => 'any' , 'no_found_rows' => true , 'update_post_meta_cache' => false , 'update_post_term_cache' => false , ] ; if ( false !== $ id ) { $ query_args [ 'p' ] = $ id ; } else { $ query_args [ 'name' ] = $ slug ; } $ query = new \ WP_Query ( apply_filters ( $ this -> get_query_filter_name ( ) , $ query_args , $ request ) ) ; if ( $ query -> have_posts ( ) ) { $ query -> the_post ( ) ; $ post = $ query -> post ; $ data = [ 'id' => $ post -> ID , 'slug' => $ post -> post_name , 'type' => Type :: get ( $ post ) , 'content' => Content :: get ( $ post ) , 'meta' => Meta \ Post :: get_all_post_meta ( $ post ) , ] ; wp_reset_postdata ( ) ; return $ this -> filter_data ( $ data , $ post -> ID ) ; } return new \ WP_Error ( self :: NOT_FOUND , 'Nothing found for this query' , [ 'status' => 404 ] ) ; } | Get the post . |
22,212 | private function get_query_filter_name ( ) { $ filter_format = trim ( $ this -> filter_format ( $ this -> endpoint ) , '_' ) ; return sprintf ( self :: QUERY_FILTER , $ filter_format ) ; } | Makes sure there is no more _ between and after the filter_format |
22,213 | public function endpoint_args ( ) { return [ 'id' => [ 'default' => false , 'validate_callback' => function ( $ id ) { return false === $ id || intval ( $ id ) > 0 ; } , ] , 'slug' => [ 'default' => false , 'sanitize_callback' => function ( $ slug , $ request , $ key ) { return false === $ slug ? $ slug : sanitize_text_field ( $ slug ) ; } , ] , ] ; } | Callback used for the endpoint |
22,214 | public function mergeConfig ( array $ values , bool $ invert = false ) : Configurator { $ this -> config = ( $ invert ) ? array_merge ( $ values , $ this -> config ) : array_merge ( $ this -> config , $ values ) ; return $ this ; } | Merge the values to the options array . |
22,215 | public function flushConfig ( string ... $ filter ) : Configurator { $ filter = array_flip ( $ filter ) ; $ this -> config = array_diff_key ( $ this -> config , $ filter ) ; return $ this ; } | Flush a list of options from the config array . |
22,216 | public function setOption ( string $ name , $ value ) : Configurator { $ this -> validateName ( $ name ) ; $ this -> config [ $ name ] = $ value ; return $ this ; } | Set a value to the given option . |
22,217 | public function hasOption ( string $ name ) : bool { $ this -> validateName ( $ name ) ; return array_key_exists ( $ name , $ this -> config ) ; } | Check if the option exist . |
22,218 | public function consumeOption ( string $ name ) { $ this -> validateName ( $ name ) ; if ( ! array_key_exists ( $ name , $ this -> config ) ) { return null ; } $ value = $ this -> config [ $ name ] ; $ this -> flushOption ( $ name ) ; return $ value ; } | Read then flush an option . |
22,219 | public function pushOption ( string $ name , array ... $ args ) : Configurator { $ this -> validateName ( $ name ) ; if ( empty ( $ args ) ) { throw new InvalidArgumentNumberException ( ) ; } foreach ( $ args as $ arg ) { if ( is_array ( $ arg ) ) { foreach ( $ arg as $ key => $ value ) { $ this -> config [ $ name ] [ $ key ] = $ value ; } } } return $ this ; } | Push the listed args to the named option . |
22,220 | public function flushOption ( string $ name ) : Configurator { $ this -> validateName ( $ name ) ; if ( $ this -> hasOption ( $ name ) ) { unset ( $ this -> config [ $ name ] ) ; } return $ this ; } | Flush an option . |
22,221 | public static function getInstance ( $ name ) { if ( ! self :: loaded ( $ name ) ) { throw new MissingPluginException ( [ 'plugin' => $ name ] ) ; } if ( ! Arr :: key ( $ name , self :: $ _pluginsList ) ) { $ slug = Str :: low ( $ name ) ; $ table = TableRegistry :: get ( 'Extensions.Extensions' ) ; $ entity = $ table -> find ( ) -> where ( [ 'slug' => $ slug , 'type' => EXT_TYPE_PLUGIN ] ) -> first ( ) ; self :: $ _pluginsList [ $ name ] = $ entity ; } return self :: $ _pluginsList [ $ name ] ; } | Get plugin extension instance . |
22,222 | public static function get ( String $ configName , String $ name ) : String { $ config = Config :: default ( 'ZN\Services\CDNDefaultConfiguration' ) :: get ( 'CDNLinks' ) ; $ configData = ! empty ( $ config [ $ configName ] ) ? $ config [ $ configName ] : '' ; if ( empty ( $ configData ) ) { return false ; } $ data = array_change_key_case ( $ configData ) ; $ name = strtolower ( $ name ) ; if ( isset ( $ data [ $ name ] ) ) { return $ data [ $ name ] ; } else { return $ data ; } } | Get cdn data . |
22,223 | public function getallfields ( ) { $ res = array ( ) ; foreach ( $ this -> categories as $ cat ) { foreach ( $ cat -> groups as $ group ) { foreach ( $ group -> fields as $ fld ) { $ res [ $ fld -> alias ] = $ fld ; } } } return $ res ; } | Get all fields objects |
22,224 | public function saveconfig ( ) { $ fields = $ this -> getallfields ( ) ; foreach ( $ fields as $ k => & $ v ) { $ v -> value = BRequest :: getVar ( $ k , $ v -> default ) ; } $ cfgfile = '<?php' . PHP_EOL ; foreach ( $ fields as $ fld ) { $ cfgfile .= $ fld -> getcfg ( ) ; } $ fn_config = BROOTPATH . 'config' . DIRECTORY_SEPARATOR . 'config.php' ; return file_put_contents ( $ fn_config , $ cfgfile ) ; } | Save configuration file |
22,225 | public function getDocumentCollection ( $ className ) { $ className = ltrim ( $ className , '\\' ) ; $ metadata = $ this -> metadataFactory -> getMetadataFor ( $ className ) ; $ collectionName = $ metadata -> getCollection ( ) ; if ( ! $ collectionName ) { throw MongoDBException :: documentNotMappedToCollection ( $ className ) ; } if ( ! isset ( $ this -> documentCollections [ $ className ] ) ) { $ db = $ this -> getDocumentDatabase ( $ className ) ; $ this -> documentCollections [ $ className ] = $ metadata -> isFile ( ) ? $ db -> getGridFS ( $ collectionName ) : $ db -> selectCollection ( $ collectionName ) ; } $ collection = $ this -> documentCollections [ $ className ] ; if ( $ metadata -> slaveOkay !== null ) { $ collection -> setSlaveOkay ( $ metadata -> slaveOkay ) ; } return $ this -> documentCollections [ $ className ] ; } | Returns the MongoCollection instance for a class . |
22,226 | public function getRepository ( $ documentName ) { $ documentName = ltrim ( $ documentName , '\\' ) ; if ( isset ( $ this -> repositories [ $ documentName ] ) ) { return $ this -> repositories [ $ documentName ] ; } $ metadata = $ this -> getClassMetadata ( $ documentName ) ; $ customRepositoryClassName = $ metadata -> customRepositoryClassName ; if ( $ customRepositoryClassName !== null ) { $ repository = new $ customRepositoryClassName ( $ this , $ this -> unitOfWork , $ metadata ) ; } else { $ repository = new DocumentRepository ( $ this , $ this -> unitOfWork , $ metadata ) ; } $ this -> repositories [ $ documentName ] = $ repository ; return $ repository ; } | Gets the repository for a document class . |
22,227 | public function flush ( $ document = null , array $ options = array ( ) ) { if ( null !== $ document && ! is_object ( $ document ) && ! is_array ( $ document ) ) { throw new \ InvalidArgumentException ( gettype ( $ document ) ) ; } $ this -> errorIfClosed ( ) ; $ this -> unitOfWork -> commit ( $ document , $ options ) ; } | Flushes all changes to objects that have been queued up to now to the database . This effectively synchronizes the in - memory state of managed objects with the database . |
22,228 | public function getReference ( $ documentName , $ identifier ) { $ class = $ this -> metadataFactory -> getMetadataFor ( ltrim ( $ documentName , '\\' ) ) ; if ( $ document = $ this -> unitOfWork -> tryGetById ( $ identifier , $ class ) ) { return $ document ; } $ document = $ this -> proxyFactory -> getProxy ( $ class -> name , array ( $ class -> identifier => $ identifier ) ) ; $ this -> unitOfWork -> registerManaged ( $ document , $ identifier , array ( ) ) ; return $ document ; } | Gets a reference to the document identified by the given type and identifier without actually loading it . |
22,229 | public function createDBRef ( $ document , array $ referenceMapping = null ) { if ( ! is_object ( $ document ) ) { throw new \ InvalidArgumentException ( 'Cannot create a DBRef, the document is not an object' ) ; } $ class = $ this -> getClassMetadata ( get_class ( $ document ) ) ; $ id = $ this -> unitOfWork -> getDocumentIdentifier ( $ document ) ; if ( ! $ id ) { throw new \ RuntimeException ( sprintf ( 'Cannot create a DBRef without an identifier. UnitOfWork::getDocumentIdentifier() did not return an identifier for class %s' , $ class -> name ) ) ; } if ( ! empty ( $ referenceMapping [ 'simple' ] ) ) { return $ class -> getDatabaseIdentifierValue ( $ id ) ; } $ dbRef = array ( '$ref' => $ class -> getCollection ( ) , '$id' => $ class -> getDatabaseIdentifierValue ( $ id ) , '$db' => $ this -> getDocumentDatabase ( $ class -> name ) -> getName ( ) , ) ; if ( isset ( $ class -> discriminatorField ) ) { $ dbRef [ $ class -> discriminatorField ] = isset ( $ class -> discriminatorValue ) ? $ class -> discriminatorValue : $ class -> name ; } if ( $ referenceMapping !== null && ! isset ( $ referenceMapping [ 'targetDocument' ] ) ) { $ discriminatorField = $ referenceMapping [ 'discriminatorField' ] ; $ discriminatorValue = isset ( $ referenceMapping [ 'discriminatorMap' ] ) ? array_search ( $ class -> name , $ referenceMapping [ 'discriminatorMap' ] ) : $ class -> name ; if ( $ discriminatorValue === false ) { $ discriminatorValue = $ class -> name ; } $ dbRef [ $ discriminatorField ] = $ discriminatorValue ; } return $ dbRef ; } | Returns a DBRef array for the supplied document . |
22,230 | public function download ( Request $ request , $ name = 'output' ) { $ pdf = PDF :: loadView ( 'laralum_pdf::pdf' , [ 'text' => $ request -> text ] ) ; return $ pdf -> download ( "$name.pdf" ) ; } | Download the PDF . |
22,231 | public function show ( Request $ request ) { $ pdf = PDF :: loadView ( 'laralum_pdf::pdf' , [ 'text' => $ request -> text ] ) ; return Response :: make ( $ pdf -> download ( 'output.pdf' ) , 200 , [ 'content-type' => 'application/pdf' ] ) ; } | Display the PDF . |
22,232 | public function initRootSkills ( $ overrideExisting = true ) { if ( null !== $ this -> collRootSkills && ! $ overrideExisting ) { return ; } $ this -> collRootSkills = new ObjectCollection ( ) ; $ this -> collRootSkills -> setModel ( '\gossi\trixionary\model\Skill' ) ; } | Initializes the collRootSkills collection . |
22,233 | public function getRootSkillsJoinSport ( Criteria $ criteria = null , ConnectionInterface $ con = null , $ joinBehavior = Criteria :: LEFT_JOIN ) { $ query = ChildSkillQuery :: create ( null , $ criteria ) ; $ query -> joinWith ( 'Sport' , $ joinBehavior ) ; return $ this -> getRootSkills ( $ query , $ con ) ; } | If this collection has already been initialized with an identical criteria it returns the collection . Otherwise if this FunctionPhase is new it will return an empty collection ; or if this FunctionPhase has previously been saved it will retrieve related RootSkills from storage . |
22,234 | public function getSyncParent ( $ con = null ) { $ parent = $ this -> getParentOrCreate ( $ con ) ; $ parent -> setType ( $ this -> getType ( ) ) ; $ parent -> setSkillId ( $ this -> getSkillId ( ) ) ; $ parent -> setTitle ( $ this -> getTitle ( ) ) ; if ( $ this -> getSkill ( ) && $ this -> getSkill ( ) -> isNew ( ) ) { $ parent -> setSkill ( $ this -> getSkill ( ) ) ; } return $ parent ; } | Create or Update the parent StructureNode object And return its primary key |
22,235 | public function register ( Application $ app ) { $ app [ 'db' ] = $ app -> share ( function ( $ app ) { return new Adapter ( $ app [ 'config' ] -> load ( 'db' ) ) ; } ) ; $ app [ 'db.transaction' ] = $ app -> share ( function ( $ app ) { return new Transaction ( $ app [ 'db' ] ) ; } ) ; $ app -> initializer ( 'Synapse\\Db\\TransactionAwareInterface' , function ( $ object , $ app ) { $ object -> setTransaction ( $ app [ 'db.transaction' ] ) ; return $ object ; } ) ; $ this -> registerMapperInitializer ( $ app ) ; } | Register the database adapter |
22,236 | protected function registerMapperInitializer ( Application $ app ) { $ initializer = function ( $ mapper , $ app ) { $ mapper -> setSqlFactory ( new SqlFactory ) ; } ; $ app -> initializer ( 'Synapse\Mapper\AbstractMapper' , $ initializer ) ; } | Register an initializer that injects a SQL Factory into all AbstractMappers |
22,237 | public function execute ( Framework $ framework , RequestAbstract $ request , Response $ response , $ value = null ) { $ accessLevels = $ value ; $ dataRequest = new DataRequest ( 1 , 0 , 'name' , 'ASC' ) ; $ groups = $ this -> groupManager -> find ( $ dataRequest ) ; if ( $ groups === false ) { return $ accessLevels ; } foreach ( $ groups as $ group ) { $ accessLevels [ ] = new GroupAccessLevel ( '\\Group\\' . $ group -> getUuid ( ) , $ this -> translationManager -> translate ( 'Group' , '\\Zepi\\Web\\AccessControl' ) . ' ' . $ group -> getName ( ) , $ this -> translationManager -> translate ( 'Inherits all permissions from this group.' , '\\Zepi\\Web\\AccessControl' ) , '\\Group' ) ; } return $ accessLevels ; } | Registers the groups as access levels . |
22,238 | public function displayName ( ) { if ( isset ( $ this -> data [ 'name' ] ) && config ( 'gzero.use_users_nicks' ) ) { return $ this -> data [ 'name' ] ; } if ( isset ( $ this -> data [ 'first_name' ] ) || isset ( $ this -> data [ 'last_name' ] ) ) { return $ this -> data [ 'first_name' ] . ' ' . $ this -> data [ 'last_name' ] ; } return trans ( 'gzero-core::common.anonymous' ) ; } | Get display name nick or first and last name |
22,239 | protected static function assert ( $ condition , string $ errorMessage = '' , bool $ exitOnError = false ) : bool { self :: $ totalCount ++ ; self :: $ count ++ ; if ( ! $ condition ) { $ trace = debug_backtrace ( ) ; $ errorPrefix = ( isset ( $ trace [ 1 ] [ 'class' ] ) ? ( $ trace [ 1 ] [ 'class' ] . ( isset ( $ trace [ 1 ] [ 'function' ] ) ? '::' . $ trace [ 1 ] [ 'function' ] : '' ) . ( isset ( $ trace [ 1 ] [ 'line' ] ) ? ' (' . $ trace [ 1 ] [ 'line' ] . ')' : '' ) . ' -> ' ) : '' ) . $ trace [ 0 ] [ 'class' ] . ' (' . $ trace [ 0 ] [ 'line' ] . ")\n " ; self :: addError ( $ errorPrefix . $ errorMessage ) ; self :: $ totalCountErrors ++ ; if ( $ exitOnError ) { exit ; } } return ( bool ) $ condition ; } | Simple assert of the test application |
22,240 | protected static function assertFalseException ( \ Exception $ e ) : bool { $ msg = 'EXCEPTION: ' . $ e -> getMessage ( ) ; $ msg .= "\n " . $ e -> getFile ( ) . ' (' . $ e -> getLine ( ) . ')' ; self :: assert ( false , $ msg ) ; } | Assert false and display exception |
22,241 | private static function addError ( $ message ) : void { if ( self :: $ result === false ) { self :: $ result = array ( ) ; } self :: $ result [ ] = $ message ; } | Add an error in the table |
22,242 | public static function runDirectory ( string $ path , string $ testSuffix = '/Test' , ? string $ filter = null , ? string $ exclude = '/vendor/' ) : bool { foreach ( new \ RecursiveIteratorIterator ( new \ RecursiveDirectoryIterator ( $ path , \ RecursiveDirectoryIterator :: KEY_AS_PATHNAME ) , \ RecursiveIteratorIterator :: CHILD_FIRST ) as $ file => $ info ) { if ( ! preg_match ( '#^' . $ path . '.*' . $ testSuffix . '\.php$#' , $ file ) || ( $ exclude !== null && strpos ( $ file , $ exclude ) !== false ) ) { continue ; } $ matches = [ ] ; if ( ! preg_match ( '/^.*\nnamespace ([a-zA-Z\\\\]+); *\n.*$/m' , file_get_contents ( $ file ) , $ matches ) ) { trigger_error ( $ file . ' namespace not found' ) ; } $ className = '\\' . strtr ( $ matches [ 1 ] . '/' . basename ( $ file , '.php' ) , '/' , '\\' ) ; self :: runClass ( $ className , $ filter ) ; } echo "- " . self :: $ totalCountFiles . " test file(s), " ; echo self :: $ totalCount . ' tests passed, ' ; if ( self :: $ totalCountErrors > 0 ) { echo chr ( 033 ) . '[1;31m' . self :: $ totalCountErrors . ' failed' . chr ( 033 ) . '[0;0m' ; } else { echo chr ( 033 ) . '[1;32msuccess ^^' . chr ( 033 ) . '[0;0m' ; } echo "\n" ; return ! self :: $ totalCountErrors ; } | Run recursively a testsuite in a directory . |
22,243 | private static function runClass ( string $ className , ? string $ filter ) : bool { echo Console :: beginActionMessage ( $ className ) ; flush ( ) ; if ( ! is_null ( $ filter ) && ! preg_match ( $ filter , $ className ) ) { echo Console :: endActionSkip ( ) ; flush ( ) ; return false ; } try { $ result = call_user_func ( array ( $ className , 'run' ) ) ; } catch ( \ Exception $ e ) { $ result = array ( $ e -> getMessage ( ) , 'Exception catched in the test library :' , $ e -> getFile ( ) . '(' . $ e -> getLine ( ) . ')' ) ; if ( defined ( 'APPLICATION_ENV' ) && APPLICATION_ENV == 'development' ) { echo Console :: endActionFail ( ) ; echo self :: exceptionToStr ( $ e ) ; exit ; } } if ( $ result === false ) { echo Console :: endActionOK ( ) ; } else if ( $ result === true ) { echo Console :: endActionSkip ( ) ; } else { echo Console :: endActionFail ( ) ; foreach ( $ result as $ line ) { echo ' - ' . $ line . "\n" ; } } flush ( ) ; return true ; } | Run a single test class |
22,244 | public function & ClearSession ( ) { $ this -> values = [ ] ; $ this -> errors = [ ] ; $ session = & $ this -> getSession ( ) ; $ session -> values = [ ] ; $ session -> csrf = [ ] ; $ session -> errors = [ ] ; return $ this ; } | Clear form values to empty array and clear form values in form session namespace clear form errors to empty array and clear form errors in form session namespace and clear form CSRF tokens clear CRSF tokens in form session namespace . |
22,245 | public function & SaveSession ( ) { $ session = & $ this -> getSession ( ) ; $ session -> errors = $ this -> errors ; $ session -> values = $ this -> values ; return $ this ; } | Store form values form errors and form CSRF tokens in it s own form session namespace . |
22,246 | protected function & getSession ( ) { if ( isset ( self :: $ allFormsSessions [ $ this -> id ] ) ) { $ sessionNamespace = & self :: $ allFormsSessions [ $ this -> id ] ; } else { $ sessionClass = self :: $ sessionClass ; $ toolClass = self :: $ toolClass ; $ formIdPc = $ this -> id ; if ( strpos ( $ formIdPc , '-' ) !== FALSE ) $ formIdPc = $ toolClass :: GetPascalCaseFromDashed ( $ formIdPc ) ; if ( strpos ( $ formIdPc , '_' ) !== FALSE ) $ formIdPc = $ toolClass :: GetPascalCaseFromUnderscored ( $ formIdPc ) ; $ namespaceName = '\\MvcCore\\Ext\\Form\\' . ucfirst ( $ formIdPc ) ; $ sessionNamespace = $ sessionClass :: GetNamespace ( $ namespaceName ) ; $ sessionNamespace -> SetExpirationSeconds ( $ this -> sessionExpiration ) ; if ( ! isset ( $ sessionNamespace -> values ) ) $ sessionNamespace -> values = [ ] ; if ( ! isset ( $ sessionNamespace -> csrf ) ) $ sessionNamespace -> csrf = [ ] ; if ( ! isset ( $ sessionNamespace -> errors ) ) $ sessionNamespace -> errors = [ ] ; self :: $ allFormsSessions [ $ this -> id ] = & $ sessionNamespace ; } return $ sessionNamespace ; } | Get session namespace reference with configured expiration and predefined fields values csrf and errors as arrays . |
22,247 | public function onFinderDelete ( $ context , $ table ) { if ( $ context == 'com_categories.category' ) { $ id = $ table -> id ; } elseif ( $ context == 'com_finder.index' ) { $ id = $ table -> link_id ; } else { return true ; } return $ this -> remove ( $ id ) ; } | Method to remove the link information for items that have been deleted . |
22,248 | public function onFinderAfterSave ( $ context , $ row , $ isNew ) { if ( $ context == 'com_categories.category' ) { if ( ! $ isNew && $ this -> old_access != $ row -> access ) { $ this -> itemAccessChange ( $ row ) ; } $ this -> reindex ( $ row -> id ) ; if ( ! $ isNew && $ this -> old_cataccess != $ row -> access ) { $ this -> categoryAccessChange ( $ row ) ; } } return true ; } | Smart Search after save content method . Reindexes the link information for a category that has been saved . It also makes adjustments if the access level of the category has changed . |
22,249 | public function onFinderBeforeSave ( $ context , $ row , $ isNew ) { if ( $ context == 'com_categories.category' ) { if ( ! $ isNew ) { $ this -> checkItemAccess ( $ row ) ; $ this -> checkCategoryAccess ( $ row ) ; } } return true ; } | Smart Search before content save method . This event is fired before the data is actually saved . |
22,250 | public function onFinderChangeState ( $ context , $ pks , $ value ) { if ( $ context == 'com_categories.category' ) { foreach ( $ pks as $ pk ) { $ query = clone $ this -> getStateQuery ( ) ; $ query -> where ( 'a.id = ' . ( int ) $ pk ) ; $ this -> db -> setQuery ( $ query ) ; $ item = $ this -> db -> loadObject ( ) ; $ state = null ; if ( $ item -> parent_id != 1 ) { $ state = $ item -> cat_state ; } $ temp = $ this -> translateState ( $ value , $ state ) ; $ this -> change ( $ pk , 'state' , $ temp ) ; $ this -> reindex ( $ pk ) ; } } if ( $ context == 'com_plugins.plugin' && $ value === 0 ) { $ this -> pluginDisable ( $ pks ) ; } } | Method to update the link information for items that have been changed from outside the edit screen . This is fired when the item is published unpublished archived or unarchived from the list view . |
22,251 | protected function index ( FinderIndexerResult $ item , $ format = 'html' ) { if ( JComponentHelper :: isEnabled ( $ this -> extension ) == false ) { return ; } $ item -> setLanguage ( ) ; $ path = JPATH_SITE . '/components/' . $ item -> extension . '/helpers/route.php' ; if ( is_file ( $ path ) ) { include_once $ path ; } $ extension = ucfirst ( substr ( $ item -> extension , 4 ) ) ; $ registry = new Registry ; $ registry -> loadString ( $ item -> params ) ; $ item -> params = $ registry ; $ registry = new Registry ; $ registry -> loadString ( $ item -> metadata ) ; $ item -> metadata = $ registry ; $ item -> metaauthor = $ item -> metadata -> get ( 'author' ) ; $ item -> addInstruction ( FinderIndexer :: META_CONTEXT , 'link' ) ; $ item -> addInstruction ( FinderIndexer :: META_CONTEXT , 'metakey' ) ; $ item -> addInstruction ( FinderIndexer :: META_CONTEXT , 'metadesc' ) ; $ item -> addInstruction ( FinderIndexer :: META_CONTEXT , 'metaauthor' ) ; $ item -> addInstruction ( FinderIndexer :: META_CONTEXT , 'author' ) ; $ item -> summary = FinderIndexerHelper :: prepareContent ( $ item -> summary , $ item -> params ) ; $ item -> url = $ this -> getUrl ( $ item -> id , $ item -> extension , $ this -> layout ) ; $ class = $ extension . 'HelperRoute' ; if ( class_exists ( $ class ) && method_exists ( $ class , 'getCategoryRoute' ) ) { $ item -> route = $ class :: getCategoryRoute ( $ item -> id , $ item -> language ) ; } else { $ item -> route = ContentHelperRoute :: getCategoryRoute ( $ item -> id , $ item -> language ) ; } $ item -> path = FinderIndexerHelper :: getContentPath ( $ item -> route ) ; $ title = $ this -> getItemMenuTitle ( $ item -> url ) ; if ( ! empty ( $ title ) && $ this -> params -> get ( 'use_menu_title' , true ) ) { $ item -> title = $ title ; } $ item -> state = $ this -> translateState ( $ item -> state ) ; $ item -> addTaxonomy ( 'Type' , 'Category' ) ; $ item -> addTaxonomy ( 'Language' , $ item -> language ) ; FinderIndexerHelper :: getContentExtras ( $ item ) ; $ this -> indexer -> index ( $ item ) ; } | Method to index an item . The item must be a FinderIndexerResult object . |
22,252 | protected function getListQuery ( $ query = null ) { $ db = JFactory :: getDbo ( ) ; $ query = $ query instanceof JDatabaseQuery ? $ query : $ db -> getQuery ( true ) -> select ( 'a.id, a.title, a.alias, a.description AS summary, a.extension' ) -> select ( 'a.created_user_id AS created_by, a.modified_time AS modified, a.modified_user_id AS modified_by' ) -> select ( 'a.metakey, a.metadesc, a.metadata, a.language, a.lft, a.parent_id, a.level' ) -> select ( 'a.created_time AS start_date, a.published AS state, a.access, a.params' ) ; $ case_when_item_alias = ' CASE WHEN ' ; $ case_when_item_alias .= $ query -> charLength ( 'a.alias' , '!=' , '0' ) ; $ case_when_item_alias .= ' THEN ' ; $ a_id = $ query -> castAsChar ( 'a.id' ) ; $ case_when_item_alias .= $ query -> concatenate ( array ( $ a_id , 'a.alias' ) , ':' ) ; $ case_when_item_alias .= ' ELSE ' ; $ case_when_item_alias .= $ a_id . ' END as slug' ; $ query -> select ( $ case_when_item_alias ) -> from ( '#__categories AS a' ) -> where ( $ db -> quoteName ( 'a.id' ) . ' > 1' ) ; return $ query ; } | Method to get the SQL query used to retrieve the list of content items . |
22,253 | protected function getStateQuery ( ) { $ query = $ this -> db -> getQuery ( true ) -> select ( $ this -> db -> quoteName ( 'a.id' ) ) -> select ( $ this -> db -> quoteName ( 'a.parent_id' ) ) -> select ( 'a.' . $ this -> state_field . ' AS state, c.published AS cat_state' ) -> select ( 'a.access, c.access AS cat_access' ) -> from ( $ this -> db -> quoteName ( '#__categories' ) . ' AS a' ) -> join ( 'LEFT' , '#__categories AS c ON c.id = a.parent_id' ) ; return $ query ; } | Method to get a SQL query to load the published and access states for a category and its parents . |
22,254 | public static function classExists ( $ className ) { if ( class_exists ( $ className , false ) || interface_exists ( $ className , false ) ) { return true ; } foreach ( spl_autoload_functions ( ) as $ loader ) { if ( is_array ( $ loader ) ) { if ( is_object ( $ loader [ 0 ] ) ) { if ( $ loader [ 0 ] instanceof ClassLoader ) { if ( $ loader [ 0 ] -> canLoadClass ( $ className ) ) { return true ; } } else if ( $ loader [ 0 ] -> { $ loader [ 1 ] } ( $ className ) ) { return true ; } } else if ( $ loader [ 0 ] :: $ loader [ 1 ] ( $ className ) ) { return true ; } } else if ( $ loader instanceof \ Closure ) { if ( $ loader ( $ className ) ) { return true ; } } else if ( is_string ( $ loader ) && $ loader ( $ className ) ) { return true ; } } return class_exists ( $ className , false ) || interface_exists ( $ className , false ) ; } | Checks whether a class with a given name exists . A class exists if it is either already defined in the current request or if there is an autoloader on the SPL autoload stack that is a ) responsible for the class in question and b ) is able to load a class file in which the class definition resides . |
22,255 | public function mapObjectToArray ( $ object , string $ prefix = "" ) { if ( ! is_object ( $ object ) ) { return $ object ; } if ( get_class ( $ object ) === \ stdClass :: class ) { return ( array ) $ object ; } $ objectClass = new \ ReflectionClass ( $ object ) ; $ objectProperties = $ this -> getObjectProperties ( $ objectClass ) ; $ array = array ( ) ; foreach ( $ objectProperties as $ property ) { if ( $ property -> getGetter ( ) == null && ! $ property -> isPublic ( ) ) { continue ; } $ value = $ this -> getValue ( $ object , $ property ) ; if ( $ value === null ) { continue ; } $ propertyName = $ property -> getName ( ) ; $ annotations = $ property -> getAnnotations ( ) ; $ propertyKey = empty ( $ prefix ) ? $ propertyName : $ prefix . self :: PATH_DELIMITER . $ propertyName ; if ( is_array ( $ value ) && array_key_exists ( TypeValidator :: ANNOTATION , $ annotations ) && TypeHelper :: isTypedArrayType ( $ annotations [ TypeValidator :: ANNOTATION ] ) ) { $ items = array ( ) ; foreach ( $ value as $ index => $ item ) { $ items [ ] = $ this -> mapObjectToArray ( $ item ) ; } $ array [ $ propertyKey ] = $ items ; } else { $ array [ $ propertyKey ] = $ this -> mapObjectToArray ( $ value ) ; } } return $ array ; } | Maps the provided object to an array or returns the provided object if it was of a built - in primitive type |
22,256 | public function strip ( $ postContent , $ wrap ) { $ pattern = '/' . $ wrap . '(.*?)' . $ wrap . '/s' ; $ match = preg_match ( $ pattern , $ postContent , $ matches ) ; if ( $ match ) { $ post [ 'config' ] = $ matches [ 1 ] ; $ post [ 'content' ] = str_replace ( $ matches [ 0 ] , '' , $ postContent ) ; return $ post ; } return array ( 'config' => '' , 'content' => $ postContent ) ; } | Strip the config from the post and return the config and content in an array . |
22,257 | private function listCommands ( array & $ list , $ path , $ namespace ) { $ classes = [ ] ; list_classes ( $ classes , $ path , $ namespace ) ; foreach ( $ classes as $ class ) { $ command = new $ class ; $ name = $ command -> name ( ) ; $ description = trim ( $ command -> description ( ) ? : '' ) ; $ list [ $ name ] = compact ( 'class' , 'name' , 'description' ) ; } } | Read available commands recursive from given path . |
22,258 | private function createCommandList ( ) { $ list = [ ] ; $ this -> listCommands ( $ list , __DIR__ . '/../Commands' , 'Core\Commands' ) ; if ( file_exists ( $ this -> pluginManifestOfCommands ) ) { $ list = array_merge ( $ list , include $ this -> pluginManifestOfCommands ) ; } $ this -> listCommands ( $ list , app_path ( 'Commands' ) , 'App\Commands' ) ; ksort ( $ list ) ; return $ list ; } | Create a new command list . |
22,259 | private function isCacheUpToDate ( ) { if ( ! file_exists ( $ this -> cachedFile ) ) { return false ; } $ cacheTime = filemtime ( $ this -> cachedFile ) ; $ mTime = $ this -> modificationTime ( ) ; return $ cacheTime == $ mTime ; } | Determine if the cached file is up to date with the command folder . |
22,260 | private function saveCommandListToCache ( $ list ) { if ( ! is_dir ( $ cacheDir = dirname ( $ this -> cachedFile ) ) ) { if ( ! make_dir ( $ cacheDir , 0775 ) ) { throw new RuntimeException ( sprintf ( 'Command factory was not able to create directory "%s"' , $ cacheDir ) ) ; } } if ( file_exists ( $ this -> cachedFile ) ) { unlink ( $ this -> cachedFile ) ; } if ( file_put_contents ( $ this -> cachedFile , '<?php return ' . var_export ( $ list , true ) . ';' . PHP_EOL , LOCK_EX ) === false ) { throw new RuntimeException ( sprintf ( 'Command factory was not able to save cached file "%s"' , $ this -> cachedFile ) ) ; } @ chmod ( $ this -> cachedFile , 0664 ) ; $ time = $ this -> modificationTime ( ) ; if ( ! @ touch ( $ this -> cachedFile , $ time ) ) { throw new RuntimeException ( sprintf ( 'Command factory was not able to modify time of cached file "%s"' , $ this -> cachedFile ) ) ; } } | Save the command list to the cache . |
22,261 | private function modificationTime ( ) { return max ( file_exists ( $ this -> pluginManifestOfCommands ) ? filemtime ( $ this -> pluginManifestOfCommands ) : 0 , filemtime ( __DIR__ . '/../Commands' ) , file_exists ( app_path ( 'Commands' ) ) ? filemtime ( app_path ( 'Commands' ) ) : 0 ) ; } | Gets the modification time . |
22,262 | public function getMessages ( $ elementName = null ) { if ( null === $ elementName ) { $ messages = $ this -> messages ; foreach ( $ this -> iterator as $ name => $ element ) { $ messageSet = $ element -> getMessages ( ) ; if ( ! is_array ( $ messageSet ) && ! $ messageSet instanceof Traversable || empty ( $ messageSet ) ) { continue ; } $ messages [ $ name ] = $ messageSet ; } return $ messages ; } if ( ! $ this -> has ( $ elementName ) ) { throw new Exception \ InvalidArgumentException ( sprintf ( 'Invalid element name "%s" provided to %s' , $ elementName , __METHOD__ ) ) ; } $ element = $ this -> get ( $ elementName ) ; return $ element -> getMessages ( ) ; } | Get validation error messages if any |
22,263 | public static function createFromFormat ( $ format , $ time , $ timezone = null ) { if ( null === $ timezone ) { $ timezone = self :: getServerTimezone ( ) ; } if ( null === $ timezone ) { $ parent = parent :: createFromFormat ( $ format , $ time ) ; } else { $ parent = parent :: createFromFormat ( $ format , $ time , $ timezone ) ; } if ( empty ( $ parent ) ) { throw new TypeException ( 'Could not create DateTime from the given format' ) ; } $ datetime = new self ( '@' . $ parent -> getTimestamp ( ) ) ; if ( null !== $ timezone ) { $ datetime -> setTimezone ( $ timezone ) ; } return $ datetime ; } | Create From Format |
22,264 | public function getEventsFromRootAssociations ( $ apiServiceFilterContext = null ) { $ result = [ ] ; foreach ( $ this -> getRootAssociationIDs ( ) as $ key => $ rootAssociationID ) { try { $ result [ ] = $ this -> getChildAssociationsFromAssociation ( $ rootAssociationID , $ apiServiceFilterContext ) ; } catch ( ContextException $ e ) { if ( $ key === count ( $ this -> getRootAssociationIDs ( ) ) - 1 ) { throw $ e ; } } } return $ result ; } | return a list of events from the root associations |
22,265 | public function getAnnouncementsFromRootAssociations ( $ apiServiceFilterContext = null ) { $ result = [ ] ; foreach ( $ this -> getRootAssociationIDs ( ) as $ key => $ rootAssociationID ) { try { $ result [ ] = $ this -> getAnnouncementsFromAssociation ( $ rootAssociationID , $ apiServiceFilterContext ) ; } catch ( ContextException $ e ) { if ( $ key === count ( $ this -> getRootAssociationIDs ( ) ) - 1 ) { throw $ e ; } } } return $ result ; } | return a list of announcements from the root associations |
22,266 | public function getAnnouncementsFromAssociation ( $ aid , $ apiServiceFilterContext = null ) { $ apiServiceFilterContext = $ this -> checkApiServiceFilterContext ( $ apiServiceFilterContext , $ aid ) ; $ url = $ this -> getBaseApiUrl ( ) . '/associations/' . $ aid . '/announcements' ; $ params = null ; $ xml = $ this -> queryXml ( $ url , $ apiServiceFilterContext ) ; $ this -> checkValidContext ( $ xml -> list [ self :: CO_XML_ATTRIBUT_VALID_CONTEXT ] ) ; return $ xml -> list ; } | return a list of announcements from a association |
22,267 | public function getFunctionariesFromAssociation ( $ aid , $ apiServiceFilterContext = null ) { $ apiServiceFilterContext = $ this -> checkApiServiceFilterContext ( $ apiServiceFilterContext , $ aid ) ; $ url = $ this -> getBaseApiUrl ( ) . '/associations/' . $ aid . '/functionaries' ; $ params = null ; $ xml = $ this -> queryXml ( $ url , $ apiServiceFilterContext ) ; $ this -> checkValidContext ( $ xml -> list [ self :: CO_XML_ATTRIBUT_VALID_CONTEXT ] ) ; $ filterParamters = $ apiServiceFilterContext -> getParametersArray ( ) ; for ( $ i = 0 ; $ i < count ( $ xml -> list -> functionaries -> functionary ) ; $ i ++ ) { $ functionaryChildEntry = $ xml -> list -> functionaries -> functionary [ $ i ] ; if ( isset ( $ filterParamters [ 'f_role' ] ) && preg_match ( '/(' . $ filterParamters [ 'f_role' ] . ')/' , $ functionaryChildEntry [ 'role' ] ) == 0 ) { unset ( $ xml -> list -> functionaries -> functionary [ $ i ] ) ; $ i -- ; } else { $ functionaryChildEntry -> addAttribute ( 'associationid' , $ aid ) ; } } return $ xml -> list ; } | return a list of functionaries from a association |
22,268 | public function getFunctionariesFromRootAssociations ( $ apiServiceFilterContext = null ) { $ result = [ ] ; foreach ( $ this -> getRootAssociationIDs ( ) as $ key => $ rootAssociationID ) { try { $ result [ ] = $ this -> getFunctionariesFromAssociation ( $ rootAssociationID , $ apiServiceFilterContext ) ; } catch ( ContextException $ e ) { if ( $ key === count ( $ this -> getRootAssociationIDs ( ) ) - 1 ) { throw $ e ; } } } return $ result ; } | return a list of functionaries from the root associations |
22,269 | public function getFunctionaryFromAssociation ( $ aid , $ fid , $ apiServiceFilterContext = null ) { $ apiServiceFilterContext = $ this -> checkApiServiceFilterContext ( $ apiServiceFilterContext , $ aid ) ; $ url = $ this -> getBaseApiUrl ( ) . '/associations/' . $ aid . '/functionaries/' . $ fid . '' ; $ params = null ; $ xml = $ this -> queryXml ( $ url , $ apiServiceFilterContext ) ; $ this -> checkValidContext ( $ xml -> query [ self :: CO_XML_ATTRIBUT_VALID_CONTEXT ] ) ; return $ xml -> query -> children ( ) [ 0 ] ; } | return a functionary from a association |
22,270 | protected function checkApiServiceFilterContext ( $ apiServiceFilterContext = null , $ aID = null ) { if ( is_null ( $ apiServiceFilterContext ) ) { $ resultApiServiceFilterContext = new \ RGU \ Dvoconnector \ Domain \ Filter \ GenericFilterContext ( ) ; } else { $ resultApiServiceFilterContext = clone $ apiServiceFilterContext ; } if ( is_null ( $ resultApiServiceFilterContext -> getInsideAssociationID ( ) ) && isset ( $ aID ) ) { $ resultApiServiceFilterContext -> setInsideAssociationID ( $ aID ) ; } return $ resultApiServiceFilterContext ; } | check that the filter has a inside association value |
22,271 | public function fireIfNamed ( $ event , $ payload = [ ] , $ halt = false ) { if ( ! $ event ) { return ; } return $ this -> fire ( $ event , $ payload , $ halt ) ; } | Fire an event if a name was passed |
22,272 | public function fireOnce ( $ event , $ payload = [ ] , $ halt = false ) { if ( isset ( $ this -> firedEvents [ $ event ] ) ) { return ; } return $ this -> fire ( $ event , $ payload , $ halt ) ; } | Fire an event once . The next event with this name will be ignored |
22,273 | public function fireOnceIfNamed ( $ event , $ payload = [ ] , $ halt = false ) { if ( ! $ event ) { return ; } return $ this -> fireOnce ( $ event , $ payload , $ halt ) ; } | Fire an event once if named |
22,274 | public function accepts ( $ type = null ) { if ( ! isset ( $ type ) ) { return $ this -> attributes [ 'accepts' ] ; } return in_array ( $ type , $ this -> attributes [ 'accepts' ] ) ; } | Whether or not the client accepts the specified type . If the type is omitted then a list of acceptable types is returned . |
22,275 | public function acceptsEncoding ( $ encoding = null ) { if ( ! isset ( $ encoding ) ) { return $ this -> attributes [ 'encodings' ] ; } return in_array ( $ encoding , $ this -> attributes [ 'encodings' ] ) ; } | Whether or not the client accepts the specified encoding . If the type is omitted then a list of acceptable encodings is returned . |
22,276 | public function pathToString ( $ path , $ rewrite = false ) { if ( is_string ( $ path ) ) { return $ path ; } $ str = $ this -> basePath ; if ( $ str == '/' ) { $ str = '' ; } if ( ! ( $ this -> rewrite or $ rewrite ) ) { $ str .= '/' . $ this -> scriptName ; } $ str .= '/' . implode ( '/' , array_map ( 'urlencode' , $ path ) ) ; $ str = rtrim ( $ str , '/' ) ; if ( $ str == '' ) { return '/' ; } return $ str ; } | Convert path array to a string . |
22,277 | public static function findPath ( \ Psr \ Http \ Message \ ServerRequestInterface $ request ) { $ server = $ request -> getServerParams ( ) ; $ path = $ request -> getUri ( ) -> getPath ( ) ; if ( isset ( $ server [ 'SCRIPT_NAME' ] ) ) { $ basePath = dirname ( $ server [ 'SCRIPT_NAME' ] ) ; if ( $ basePath != '/' ) { $ length = strlen ( $ basePath ) ; if ( substr ( $ path , 0 , $ length ) == $ basePath ) { $ path = substr ( $ path , $ length ) ; } } } if ( $ path == '/' or $ path == '' ) { return [ ] ; } if ( $ path [ 0 ] == '/' ) { $ path = substr ( $ path , 1 ) ; } return array_map ( 'urldecode' , explode ( '/' , $ path ) ) ; } | Find the path array for a request . |
22,278 | public function updateViability ( Elementtype $ elementtype , array $ parentIds ) { $ viabilityRepository = $ this -> entityManager -> getRepository ( 'PhlexibleElementtypeBundle:ElementtypeApply' ) ; $ viabilities = $ viabilityRepository -> findBy ( [ 'elementtypeId' => $ elementtype -> getId ( ) ] ) ; foreach ( $ viabilities as $ index => $ viability ) { if ( in_array ( $ viability -> getUnderElementtypeId ( ) , $ parentIds ) ) { unset ( $ parentIds [ array_search ( $ viability -> getUnderElementtypeId ( ) , $ parentIds ) ] ) ; unset ( $ viabilities [ $ index ] ) ; } } foreach ( $ parentIds as $ parentId ) { $ viability = new ElementtypeApply ( ) ; $ viability -> setElementtypeId ( $ elementtype -> getId ( ) ) -> setUnderElementtypeId ( $ parentId ) ; $ this -> entityManager -> persist ( $ viability ) ; } foreach ( $ viabilities as $ viability ) { $ this -> entityManager -> remove ( $ viability ) ; } $ this -> entityManager -> flush ( ) ; } | Update viability . |
22,279 | public function decoratePublishedQuery ( Event $ event ) { $ query = $ event -> subject ( ) ; $ query -> select ( [ 'Pages.id' ] ) -> join ( [ 'Pages' => [ 'table' => 'cms_pages' , 'type' => 'LEFT' , 'conditions' => [ 'MenuItems.foreign_model = "Wasabi/Cms.Pages"' , 'MenuItems.foreign_id = Pages.id' , 'Pages.status' => Page :: STATUS_PUBLISHED ] ] ] ) ; } | Decorate the given query by joining the PagesTable . |
22,280 | private function slackify ( $ data ) { $ fields = array ( ) ; foreach ( $ data as $ key => $ value ) { $ obj = new \ stdClass ( ) ; $ obj -> title = $ key ; $ obj -> value = $ value ; $ obj -> short = true ; $ fields [ ] = $ obj ; } return array ( 'text' => sprintf ( '%s - %s (%s)' , $ data [ 'projectname' ] , $ data [ 'task' ] , $ data [ 'step' ] ) , 'fields' => $ fields ) ; } | Format the data in slack format |
22,281 | public function call ( $ subject , $ inherentParams = [ ] ) { $ reflectionFunction = new ReflectionFunction ( $ subject ) ; $ reflectionParameters = $ this -> getReflectionParameters ( $ reflectionFunction , count ( $ inherentParams ) ) ; $ dependentInstances = [ ] ; foreach ( $ reflectionParameters as $ reflectionParameter ) { $ dependentInstances [ ] = $ this -> getDependentByParameter ( $ reflectionParameter ) -> getInstance ( ) ; } $ params = array_merge ( $ dependentInstances , $ inherentParams ) ; $ closure = $ reflectionFunction -> getClosure ( ) ; return call_user_func_array ( $ closure , $ params ) ; } | reverse a function and save singleton |
22,282 | protected function getReflectionParameters ( $ reflection , $ inherentNumber ) { $ reflectionParameters = $ reflection -> getParameters ( ) ; return array_slice ( $ reflectionParameters , 0 , count ( $ reflectionParameters ) - $ inherentNumber ) ; } | get instances of params from Reflection |
22,283 | public function getParams ( $ reflectionClass , $ method , $ inherentNumber = 0 ) { $ instances = [ ] ; if ( ! $ reflectionClass -> hasMethod ( $ method ) ) { return $ instances ; } $ reflection = $ reflectionClass -> getMethod ( $ method ) ; $ reflectionParameters = $ this -> getReflectionParameters ( $ reflection , $ inherentNumber ) ; foreach ( $ reflectionParameters as $ reflectionParameter ) { $ instances [ ] = $ this -> getDependentByParameter ( $ reflectionParameter ) -> getInstance ( ) ; } return $ instances ; } | instantiation param list of method and save |
22,284 | public function match ( RouteCollection $ collection , Request $ request ) { $ this -> collection = $ collection ; $ this -> request = $ request ; return $ this -> voter -> vote ( $ this -> getCandidates ( ) , $ request ) ; } | Matches current Request to Route |
22,285 | public function getCandidates ( ) { $ candidates = array ( ) ; foreach ( $ this -> collection -> all ( ) as $ name => $ route ) { $ specs = array ( ) ; preg_match_all ( '/\{\w+\}/' , $ route -> getPath ( ) , $ matches ) ; if ( isset ( $ matches [ 0 ] ) ) { $ specs = $ matches [ 0 ] ; } foreach ( $ specs as $ spec ) { $ param = substr ( $ spec , 1 , - 1 ) ; $ regexSpec = '\\' . $ spec . '\\' ; $ requirements = $ route -> getRequirements ( ) ; if ( isset ( $ requirements [ $ param ] ) ) { $ route -> setRegex ( str_replace ( $ spec , $ this -> getRegexOperand ( $ requirements [ $ param ] ) , $ route -> getRegex ( ) ) ) ; } } $ route -> setRegex ( '^' . '/' . ltrim ( trim ( $ route -> getRegex ( ) ) , '/' ) . '/?$' ) ; $ route -> setRegex ( '/' . str_replace ( '/' , '\/' , $ route -> getRegex ( ) ) . '/' ) ; if ( preg_match ( $ route -> getRegex ( ) , $ this -> request -> getPathInfo ( ) ) ) { $ candidates [ ] = $ route ; } } return $ candidates ; } | Gets list of candidate Route objects for request |
22,286 | public static function base64encode ( $ input ) { return strtr ( base64_encode ( $ input ) , key ( self :: $ urlSafe ) , current ( self :: $ urlSafe ) ) ; } | Perform a URL safe base64 encode |
22,287 | public static function base64decode ( $ input ) { return base64_decode ( str_pad ( strtr ( $ input , current ( self :: $ urlSafe ) , key ( self :: $ urlSafe ) ) , strlen ( $ input ) % 4 , '=' , STR_PAD_RIGHT ) ) ; } | Perform a URL safe base 64 decode |
22,288 | private static function xor ( $ input , $ secret = null ) { $ inputSize = strlen ( $ input ) ; $ secretSize = strlen ( $ secret ) ; for ( $ y = 0 , $ x = 0 ; $ y < $ inputSize ; $ y ++ , $ x ++ ) { if ( $ x >= $ secretSize ) $ x = 0 ; $ input [ $ y ] = $ input [ $ y ] ^ $ secret [ $ x ] ; } return $ input ; } | Perform the XOR |
22,289 | public static function add ( $ key , $ value ) { $ data = ( array ) static :: get ( $ key , [ ] ) ; $ data [ ] = $ value ; static :: set ( $ key , $ data ) ; } | Add a value to a key . If the value is not an array make it one . |
22,290 | public static function get ( $ key , $ default = null ) { $ value = Hash :: get ( static :: $ _config , $ key ) ; if ( $ value === null ) { return $ default ; } return $ value ; } | Grab a value from the current configuration . |
22,291 | private function relationToArray ( RelationOverride $ relation ) { if ( $ relation -> type && ! is_numeric ( $ relation -> type ) ) { $ relation -> type = constant ( ClassMetadata :: class . '::' . $ relation -> type ) ; } return array_filter ( [ 'type' => $ relation -> type , 'targetEntity' => $ relation -> targetEntity , 'fieldName' => $ relation -> name , 'inversedBy' => $ relation -> inversedBy , 'mappedBy' => $ relation -> mappedBy , 'fetch' => $ relation -> fetch , 'cascade' => $ relation -> cascade , 'orphanRemoval' => $ relation -> orphanRemoval , ] ) ; } | Parse the given RelationOverride as array |
22,292 | private function joinColumnToArray ( JoinColumn $ joinColumn ) { return [ 'name' => $ joinColumn -> name , 'unique' => $ joinColumn -> unique , 'nullable' => $ joinColumn -> nullable , 'onDelete' => $ joinColumn -> onDelete , 'columnDefinition' => $ joinColumn -> columnDefinition , 'referencedColumnName' => $ joinColumn -> referencedColumnName , ] ; } | Parse the given JoinColumn as array |
22,293 | public function create ( ) { $ class = $ this -> getClass ( ) ; $ form = new $ class ( ) ; $ schema = $ this -> schemaManager -> create ( ) ; $ schema -> setObjectClass ( $ this -> postManager -> getClass ( ) ) ; $ form -> setSchema ( $ schema ) ; return $ form ; } | Create a new form instance . |
22,294 | public function hasReplacedParameter ( array $ parameter ) { foreach ( $ this -> replacedParameters as $ replacedParameter ) { if ( $ replacedParameter [ 'column' ] === $ parameter [ 'column' ] && $ replacedParameter [ 'value' ] === $ parameter [ 'value' ] ) { return true ; } } return false ; } | Validate the existence of a replaced parameter . |
22,295 | protected function build ( ArrayNodeDefinition $ rootNode ) : void { $ rootNode -> children ( ) -> integerNode ( 'max_items' ) -> defaultValue ( 20 ) -> info ( 'How much for max items' ) -> end ( ) ; } | Build the config tree . |
22,296 | public function options ( ) { if ( request ( ) -> has ( 'language' ) ) { return HCMenuGroups :: select ( "id" , "name" ) -> where ( 'language_code' , request ( ) -> input ( 'language' ) ) -> orderBy ( 'sequence' ) -> take ( 50 ) -> get ( ) ; } return [ ] ; } | Search for users |
22,297 | public function executeAndReturnContent ( ) { ob_start ( ) ; Output :: $ controller = WebApp :: $ page -> controller ; include $ this -> file ; $ content = ob_get_contents ( ) ; ob_clean ( ) ; return $ content ; } | Return the view content |
22,298 | private function validate ( ) { $ errors = [ ] ; foreach ( $ this -> eventDetails as $ key => $ value ) { if ( strpos ( $ key , 'tp_' ) !== false ) { $ errors [ $ key ] = 'Property names cannot start with the reserved prefix \'tp_\'' ; } if ( strpos ( $ key , '.' ) !== false ) { $ errors [ $ key ] = 'Property names cannot contain a period (.)' ; } if ( strcmp ( $ key , '_id' ) == 0 ) { $ errors [ $ key ] = 'Top level properties cannot be named \'_id\'' ; } } if ( ! empty ( $ errors ) ) { throw new InvalidPropertyNameException ( $ errors ) ; } } | Checks if an event is valid for Connect . |
22,299 | private function process ( & $ details ) { foreach ( $ details as & $ value ) { if ( is_array ( $ value ) ) { $ this -> process ( $ value ) ; continue ; } if ( $ value instanceof \ DateTime ) { $ value = $ value -> format ( \ DateTime :: ISO8601 ) ; continue ; } } } | Recursively converts any nested DateTime instances to ISO8601 strings in preparation for serialization . Note mutates the supplied array . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.