idx int64 0 241k | question stringlengths 64 6.21k | target stringlengths 5 803 |
|---|---|---|
227,500 | private function find ( $ value , $ add = false ) { $ hash = self :: hash ( $ value ) ; if ( array_key_exists ( $ hash , $ this -> objects ) ) { return true ; } else if ( $ add ) { $ this -> objects [ $ hash ] = $ value ; } return false ; } | Finds the given value and returns true if it was found . Otherwise return false . |
227,501 | protected function _generateModule ( $ oScaffold ) { $ oSmarty = $ this -> _getSmarty ( ) ; $ oSmarty -> assign ( 'oScaffold' , $ oScaffold ) ; if ( $ oScaffold -> sVendor ) { $ this -> _generateVendorDir ( $ oScaffold -> sVendor ) ; } $ sModuleDir = $ this -> _getModuleDir ( $ oScaffold -> sVendor , $ oScaffold -> sMo... | Generate module from scaffold object |
227,502 | protected function _copyAndParseDir ( $ sFrom , $ sTo , array $ aNameMap = array ( ) ) { $ oFileInfos = new \ RecursiveIteratorIterator ( new \ RecursiveDirectoryIterator ( $ sFrom , \ RecursiveDirectoryIterator :: SKIP_DOTS ) ) ; if ( ! file_exists ( $ sTo ) ) { mkdir ( $ sTo ) ; } foreach ( $ oFileInfos as $ oFileInf... | Copies files from directory parses all files and puts parsed content to another directory |
227,503 | protected function _copyAndParseFile ( $ sFrom , $ sTo ) { $ this -> _createMissingFolders ( $ sTo ) ; $ sTo = preg_replace ( '/\.tpl$/' , '' , $ sTo ) ; if ( preg_match ( '/\.tpl$/' , $ sFrom ) ) { $ oSmarty = $ this -> _getSmarty ( ) ; $ sContent = $ oSmarty -> fetch ( $ sFrom ) ; } else { $ sContent = file_get_conte... | Copies file from one directory to another parses file if original file extension is . tpl |
227,504 | protected function _createMissingFolders ( $ sFilePath ) { $ sPath = dirname ( $ sFilePath ) ; if ( ! file_exists ( $ sPath ) ) { mkdir ( $ sPath , 0777 , true ) ; } } | Create missing folders of file path |
227,505 | protected function _generateVendorDir ( $ sVendor ) { $ sVendorDir = $ this -> _sModuleDir . $ sVendor . DIRECTORY_SEPARATOR ; if ( ! file_exists ( $ sVendorDir ) ) { mkdir ( $ sVendorDir ) ; file_put_contents ( $ sVendorDir . 'vendormetadata.php' , '<?php' ) ; } } | Generate vendor directory |
227,506 | protected function _buildScaffold ( ) { $ oScaffold = new \ stdClass ( ) ; $ oScaffold -> sVendor = strtolower ( $ this -> _getUserInput ( 'Vendor Prefix' , true ) ) ; $ blFirstRequest = true ; do { if ( ! $ blFirstRequest ) { $ this -> output -> writeLn ( 'Module path or id is taken with given title' ) ; } else { $ bl... | Build scaffold object from user inputs |
227,507 | protected function _getUserInput ( $ sText , $ bAllowEmpty = false ) { $ questionHelper = $ this -> getHelper ( 'question' ) ; do { $ sTitle = "$sText: " . ( $ bAllowEmpty ? '[optional] ' : '[required] ' ) ; $ question = new Question ( $ sTitle ) ; $ sInput = $ questionHelper -> ask ( $ this -> input , $ this -> output... | Get user input |
227,508 | protected function _parseTimestamp ( $ timestamp ) { if ( is_null ( $ timestamp ) ) return AbstractQuery :: getCurrentTimestamp ( ) ; if ( ! AbstractQuery :: isValidTimestamp ( $ timestamp ) ) { if ( $ sTime = strtotime ( $ timestamp ) ) { $ timestamp = date ( 'YmdHis' , $ sTime ) ; } else { throw oxNew ( ConsoleExcept... | Parse timestamp from user input |
227,509 | public function parseNotification ( $ notification = [ ] , $ authenticate = true ) { $ notificationWalk = [ ] ; array_walk ( $ notification , function ( $ val , $ key ) use ( & $ notificationWalk ) { $ key = trim ( rawurldecode ( $ key ) ) ; $ val = trim ( rawurldecode ( $ val ) ) ; $ notificationWalk [ $ key ] = $ val... | Parse and Authenticate the incoming notification from Genesis |
227,510 | public function initReconciliation ( ) { $ type = '' ; if ( $ this -> isAPINotification ( ) ) { $ type = 'NonFinancial\Reconcile\Transaction' ; } elseif ( $ this -> isWPFNotification ( ) ) { $ type = 'WPF\Reconcile' ; } $ request = new \ Genesis \ Genesis ( $ type ) ; try { $ request -> request ( ) -> setUniqueId ( $ t... | Reconcile with the Payment Gateway to get the latest status on the transaction |
227,511 | public function isAuthentic ( ) { if ( ! isset ( $ this -> unique_id ) || ! isset ( $ this -> notificationObj -> signature ) ) { throw new \ Genesis \ Exceptions \ InvalidArgument ( 'Missing field(s), required for validation!' ) ; } $ messageSig = trim ( $ this -> notificationObj -> signature ) ; $ customerPwd = trim (... | Verify the signature on the parsed Notification |
227,512 | public function isAPINotification ( ) { return ( bool ) ( isset ( $ this -> notificationObj -> unique_id ) && ! empty ( $ this -> notificationObj -> unique_id ) ) ; } | Is this API notification? |
227,513 | public function isWPFNotification ( ) { return ( bool ) ( isset ( $ this -> notificationObj -> wpf_unique_id ) && ! empty ( $ this -> notificationObj -> wpf_unique_id ) ) ; } | Is this WPF Notification? |
227,514 | public function checkForErrors ( ) { $ errNo = curl_errno ( $ this -> curlHandle ) ; $ errStr = curl_error ( $ this -> curlHandle ) ; if ( $ errNo > 0 ) { throw new \ Genesis \ Exceptions \ ErrorNetwork ( $ errStr , $ errNo ) ; } } | Check whether or not a cURL request is successful |
227,515 | public function setNationalId ( $ value ) { if ( strlen ( $ value ) > $ this -> getNationalIdLen ( ) ) { throw new ErrorParameter ( "National Identifier can be max {$this->getNationalIdLen()} characters." ) ; } $ this -> national_id = $ value ; return $ this ; } | National Identifier number of the customer |
227,516 | public function parseDocument ( $ xmlDocument ) { $ reader = new \ XMLReader ( ) ; $ reader -> open ( 'data:text/plain;base64,' . base64_encode ( $ xmlDocument ) ) ; if ( $ this -> skipRootNode ) { $ reader -> read ( ) ; } $ this -> stdClassObj = self :: readerLoop ( $ reader ) ; } | Parse a document to an stdClass |
227,517 | public function readerLoop ( $ reader ) { $ tree = new \ stdClass ( ) ; while ( $ reader -> read ( ) ) { switch ( $ reader -> nodeType ) { case \ XMLReader :: END_ELEMENT : return $ tree ; break ; case \ XMLReader :: ELEMENT : $ this -> processElement ( $ reader , $ tree ) ; if ( $ reader -> hasAttributes ) { $ this ->... | Read through the entire document |
227,518 | public function processElement ( & $ reader , & $ tree ) { $ name = $ reader -> name ; if ( isset ( $ tree -> $ name ) ) { if ( is_a ( $ tree -> $ name , 'stdClass' ) ) { $ currentEl = $ tree -> $ name ; $ tree -> $ name = new \ ArrayObject ( ) ; $ tree -> $ name -> append ( $ currentEl ) ; } if ( is_a ( $ tree -> $ na... | Process XMLReader element |
227,519 | public function processAttributes ( & $ reader , & $ tree ) { $ name = $ reader -> name ; $ node = new \ stdClass ( ) ; $ node -> attr = new \ stdClass ( ) ; while ( $ reader -> moveToNextAttribute ( ) ) { $ node -> attr -> $ name = $ reader -> value ; } if ( isset ( $ tree -> $ name ) && is_a ( $ tree -> $ name , 'Arr... | Process element attributes |
227,520 | public function getAllCommands ( ) { if ( ! class_exists ( 'oxConsoleCommand' ) ) class_alias ( Command :: class , 'oxConsoleCommand' ) ; $ commands = $ this -> getCommandsFromCore ( ) ; $ commandsFromModules = $ this -> getCommandsFromModules ( ) ; $ commandsFromComposer = $ this -> getCommandsFromComposer ( ) ; retur... | Get all available command objects . |
227,521 | private function getCommandsFromModules ( ) { $ oConfig = Registry :: getConfig ( ) ; if ( ! class_exists ( ModuleList :: class ) ) { print "ERROR: Oxid ModuleList class can not be loaded, please run vendor/bin/oe-eshop-unified_namespace_generator" ; } else { try { $ moduleList = oxNew ( ModuleList :: class ) ; $ modul... | Collect all available commands from modules . |
227,522 | private function getPathsOfAvailableModules ( ) { $ config = Registry :: getConfig ( ) ; $ modulesRootPath = $ config -> getModulesDir ( ) ; $ modulePaths = $ config -> getConfigParam ( 'aModulePaths' ) ; if ( ! is_dir ( $ modulesRootPath ) ) return [ ] ; if ( ! is_array ( $ modulePaths ) ) return [ ] ; $ fullModulePat... | Return list of paths to all available modules . |
227,523 | private function getPhpFilesMatchingPatternForCommandFromGivenPath ( $ path ) { $ folders = [ 'Commands' , 'commands' , 'Command' ] ; foreach ( $ folders as $ f ) { $ cPath = $ path . DIRECTORY_SEPARATOR . $ f . DIRECTORY_SEPARATOR ; if ( ! is_dir ( $ cPath ) ) { continue ; } $ files = glob ( "$cPath*[cC]ommand\.php" )... | Return list of PHP files matching Command specific pattern . |
227,524 | private function getPhpFilesMatchingPatternForCommandFromGivenPaths ( $ paths ) { return $ this -> getFlatArray ( array_map ( function ( $ path ) { return $ this -> getPhpFilesMatchingPatternForCommandFromGivenPath ( $ path ) ; } , $ paths ) ) ; } | Helper method for getPhpFilesMatchingPatternForCommandFromGivenPath |
227,525 | private function getAllClassesFromPhpFile ( $ pathToPhpFile ) { $ classesBefore = get_declared_classes ( ) ; try { require_once $ pathToPhpFile ; } catch ( \ Throwable $ exception ) { print "Can not add Command $pathToPhpFile:\n" ; print $ exception -> getMessage ( ) . "\n" ; } $ classesAfter = get_declared_classes ( )... | Get list of defined classes from given PHP file . |
227,526 | private function getAllClassesFromPhpFiles ( $ pathToPhpFiles ) { return $ this -> getFlatArray ( array_map ( function ( $ pathToPhpFile ) { return $ this -> getAllClassesFromPhpFile ( $ pathToPhpFile ) ; } , $ pathToPhpFiles ) ) ; } | Helper method for getAllClassesFromPhpFile |
227,527 | private function getObjectsFromClasses ( $ classes ) { $ objects = array_map ( function ( $ class ) { try { return new $ class ; } catch ( \ Throwable $ ex ) { print "Can not add command from class $class:\n" ; print $ ex -> getMessage ( ) . "\n" ; } } , $ classes ) ; $ objects = array_filter ( $ objects , function ( $... | Convert given list of classes to objects . |
227,528 | public function getHydratorForEntity ( $ value ) { $ entityMetadata = $ this -> getMetadataMap ( ) [ ClassUtils :: getRealClass ( get_class ( $ value ) ) ] ; $ objectManagerClass = $ this -> getDoctrineHydratorConfig ( ) [ $ entityMetadata [ 'hydrator' ] ] [ 'object_manager' ] ; return new DoctrineHydrator ( $ this -> ... | Look up the object manager for the given entity and create a basic hydrator |
227,529 | public function extract ( $ value ) { if ( is_null ( $ value ) ) { return $ value ; } $ entityValues = $ this -> getHydratorForEntity ( $ value ) -> extract ( $ value ) ; $ entityMetadata = $ this -> getMetadataMap ( ) [ ClassUtils :: getRealClass ( get_class ( $ value ) ) ] ; $ link = new Link ( 'self' ) ; $ link -> s... | Return a HAL entity with just a self link |
227,530 | protected function getRiskParamsStructure ( ) { return [ 'ssn' => $ this -> risk_ssn , 'mac_address' => $ this -> risk_mac_address , 'session_id' => $ this -> risk_session_id , 'user_id' => $ this -> risk_user_id , 'user_level' => $ this -> risk_user_level , 'email' => $ this -> risk_email , 'phone' => $ this -> risk_p... | Builds an array list with all Risk Params |
227,531 | public function populateNodes ( $ structure ) { try { $ this -> output = json_encode ( $ structure ) ; } catch ( \ Exception $ e ) { throw new \ Genesis \ Exceptions \ InvalidArgument ( 'Invalid data/tree' ) ; } } | Convert multi - dimensional array to JSON object |
227,532 | public function toArray ( ) { return [ 'order_tax_amount' => CurrencyUtils :: amountToExponent ( $ this -> getOrderTaxAmount ( ) , $ this -> currency ) , 'items' => array_map ( function ( $ item ) { return [ 'item' => $ item -> toArray ( ) ] ; } , $ this -> items ) ] ; } | Return items request attributes |
227,533 | protected static function _tableExists ( $ sTable ) { $ oConfig = Registry :: getConfig ( ) ; $ sDbName = $ oConfig -> getConfigParam ( 'dbName' ) ; $ sQuery = " SELECT 1 FROM information_schema.tables WHERE table_schema = ? AND table_name = ? " ; return ( bool ) Datab... | Table exists in database? |
227,534 | protected static function _columnExists ( $ sTable , $ sColumn ) { $ oConfig = Registry :: getConfig ( ) ; $ sDbName = $ oConfig -> getConfigParam ( 'dbName' ) ; $ sSql = 'SELECT 1 FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = ? AND ... | Column exists in specific table? |
227,535 | public static function getPHPVersion ( ) { if ( ! defined ( 'PHP_VERSION_ID' ) ) { list ( $ major , $ minor , $ release ) = explode ( '.' , PHP_VERSION ) ; define ( 'PHP_VERSION_ID' , ( ( $ major * 10000 ) + ( $ minor * 100 ) + $ release ) ) ; } return ( int ) PHP_VERSION_ID ; } | Helper to get the current PHP version |
227,536 | public static function pascalToSnakeCase ( $ input ) { preg_match_all ( '!([A-Z][A-Z0-9]*(?=$|[A-Z][a-z0-9])|[A-Za-z][a-z0-9]+)!' , $ input , $ matches ) ; foreach ( $ matches [ 0 ] as & $ match ) { $ match = ( $ match == strtoupper ( $ match ) ) ? strtolower ( $ match ) : lcfirst ( $ match ) ; } return implode ( '_' ,... | Convert PascalCase string to a SnakeCase useful for argument parsing |
227,537 | public static function isArrayKeyExists ( $ key , $ arr ) { if ( ! self :: isValidArray ( $ arr ) ) { return false ; } return array_key_exists ( $ key , $ arr ) ; } | Check if the passed key exists in the supplied array |
227,538 | public static function getSortedArrayByValue ( $ arr ) { $ duplicate = self :: copyArray ( $ arr ) ; if ( $ duplicate === null ) { return null ; } asort ( $ duplicate ) ; return $ duplicate ; } | Sorts an array by value and returns a new instance |
227,539 | public static function appendItemsToArrayObj ( & $ arrObj , $ key , $ values ) { if ( ! $ arrObj instanceof \ ArrayObject ) { return null ; } $ arr = $ arrObj -> getArrayCopy ( ) ; $ commonArrKeyValues = Common :: isArrayKeyExists ( $ key , $ arr ) ? $ arr [ $ key ] : [ ] ; $ arr [ $ key ] = array_merge ( $ commonArrKe... | Appends items to an ArrayObject by key |
227,540 | public static function isValidXMLName ( $ tag ) { if ( ! is_array ( $ tag ) ) { return preg_match ( '/^[a-z_]+[a-z0-9\:\-\.\_]*[^:]*$/i' , $ tag , $ matches ) && reset ( $ matches ) == $ tag ; } return false ; } | Check if the passed argument is a valid XML tag name |
227,541 | public static function stringToBoolean ( $ string ) { $ flag = filter_var ( $ string , FILTER_VALIDATE_BOOLEAN , FILTER_NULL_ON_FAILURE ) ; if ( $ flag ) { return true ; } elseif ( is_null ( $ flag ) ) { return $ string ; } return false ; } | Evaluate a boolean expression from String or return the string itself |
227,542 | public static function isBase64Encoded ( $ input ) { if ( $ input && @ base64_encode ( @ base64_decode ( $ input , true ) ) === $ input ) { return true ; } return false ; } | Check if a string is base64 Encoded |
227,543 | public static function arrayContainsArrayItems ( $ arr ) { if ( ! self :: isValidArray ( $ arr ) ) { return false ; } foreach ( $ arr as $ item ) { if ( self :: isValidArray ( $ item ) ) { return true ; } } return false ; } | Check if an array has array items |
227,544 | public static function isClassAbstract ( $ className ) { if ( ! class_exists ( $ className ) ) { return false ; } $ reflectionClass = new \ ReflectionClass ( $ className ) ; return $ reflectionClass -> isAbstract ( ) ; } | Determines if the given class is Instantiable or not Helps to prevent from creating an instance of an abstract class |
227,545 | public static function verify ( ) { self :: checkSystemVersion ( ) ; self :: isFunctionExists ( 'bcmul' , self :: getErrorMessage ( 'bcmath' ) ) ; self :: isFunctionExists ( 'bcdiv' , self :: getErrorMessage ( 'bcmath' ) ) ; self :: isFunctionExists ( 'filter_var' , self :: getErrorMessage ( 'filter' ) ) ; self :: isFu... | Check if the current system fulfils the project s dependencies |
227,546 | public static function checkSystemVersion ( ) { if ( \ Genesis \ Utils \ Common :: compareVersions ( self :: $ minPHPVersion , '<' ) ) { throw new \ Exception ( self :: getErrorMessage ( 'system' ) ) ; } } | Check the PHP interpreter version we re currently running |
227,547 | public static function getErrorMessage ( $ name ) { $ messages = [ 'system' => 'Unsupported PHP version, please upgrade!' . PHP_EOL . 'This library requires PHP version ' . self :: $ minPHPVersion . ' or newer.' , 'bcmath' => 'BCMath extension is required!' . PHP_EOL . 'Please install the extension or rebuild with "--e... | Get error message for certain type |
227,548 | public function populateNodes ( $ data ) { if ( ! \ Genesis \ Utils \ Common :: isValidArray ( $ data ) ) { throw new \ Genesis \ Exceptions \ InvalidArgument ( 'Invalid data structure' ) ; } reset ( $ data ) ; $ this -> iterateArray ( key ( $ data ) , reset ( $ data ) ) ; $ this -> context -> endDocument ( ) ; } | Insert tree - structured array as nodes in XMLWriter and end the current Document . |
227,549 | public function iterateArray ( $ name , $ data ) { if ( \ Genesis \ Utils \ Common :: isValidXMLName ( $ name ) ) { $ this -> context -> startElement ( $ name ) ; } foreach ( $ data as $ key => $ value ) { if ( is_null ( $ value ) ) { continue ; } if ( $ key === '@attributes' ) { $ this -> writeAttribute ( $ value ) ; ... | Recursive iteration over array |
227,550 | public function writeAttribute ( $ value ) { if ( is_array ( $ value ) ) { foreach ( $ value as $ attrName => $ attrValue ) { $ this -> context -> writeAttribute ( $ attrName , $ attrValue ) ; } } } | Write Element s Attribute |
227,551 | public function writeCData ( $ value ) { if ( is_array ( $ value ) ) { foreach ( $ value as $ attrValue ) { $ this -> context -> writeCData ( $ attrValue ) ; } } else { $ this -> context -> writeCData ( $ value ) ; } } | Write Element s CData |
227,552 | public function writeText ( $ value ) { if ( is_array ( $ value ) ) { foreach ( $ value as $ attrValue ) { $ this -> context -> text ( $ attrValue ) ; } } else { $ this -> context -> text ( $ value ) ; } } | Write Element s Text |
227,553 | public function writeElement ( $ key , $ value ) { if ( is_array ( $ value ) ) { $ this -> iterateArray ( $ key , $ value ) ; } else { $ value = \ Genesis \ Utils \ Common :: booleanToString ( $ value ) ; $ this -> context -> writeElement ( $ key , $ value ) ; } } | Write XML Element |
227,554 | public static function range ( $ start , $ count ) { if ( $ count < 0 ) { throw new OutOfRangeException ( '$count must be not be negative.' ) ; } return new Linq ( range ( $ start , $ start + $ count - 1 ) ) ; } | Generates a sequence of integral numbers within a specified range . |
227,555 | public function skip ( $ count ) { $ innerIterator = $ this -> iterator ; if ( $ innerIterator instanceof \ ArrayIterator ) { if ( $ count >= $ innerIterator -> count ( ) ) { return new Linq ( [ ] ) ; } } if ( ! ( $ innerIterator instanceof \ Iterator ) ) { $ innerIterator = new \ IteratorIterator ( $ innerIterator ) ;... | Bypasses a specified number of elements and then returns the remaining elements . |
227,556 | public function take ( $ count ) { if ( $ count == 0 ) { return new Linq ( [ ] ) ; } $ innerIterator = $ this -> iterator ; if ( ! ( $ innerIterator instanceof \ Iterator ) ) { $ innerIterator = new \ IteratorIterator ( $ innerIterator ) ; } return new Linq ( new \ LimitIterator ( $ innerIterator , 0 , $ count ) ) ; } | Returns a specified number of contiguous elements from the start of a sequence |
227,557 | public function all ( callable $ func ) { foreach ( $ this -> iterator as $ current ) { $ match = LinqHelper :: getBoolOrThrowException ( $ func ( $ current ) ) ; if ( ! $ match ) { return false ; } } return true ; } | Determines whether all elements satisfy a condition . |
227,558 | public function count ( ) { if ( $ this -> iterator instanceof Countable ) { return $ this -> iterator -> count ( ) ; } return iterator_count ( $ this -> iterator ) ; } | Counts the elements of this Linq sequence . |
227,559 | public function sum ( callable $ func = null ) { $ sum = 0 ; $ iterator = $ this -> getSelectIteratorOrInnerIterator ( $ func ) ; foreach ( $ iterator as $ value ) { if ( ! is_numeric ( $ value ) ) { throw new UnexpectedValueException ( "sum() only works on numeric values." ) ; } $ sum += $ value ; } return $ sum ; } | Gets the sum of all items or by invoking a transform function on each item to get a numeric value . |
227,560 | public function min ( callable $ func = null ) { $ min = null ; $ iterator = $ this -> getSelectIteratorOrInnerIterator ( $ func ) ; foreach ( $ iterator as $ value ) { if ( ! is_numeric ( $ value ) && ! is_string ( $ value ) && ! ( $ value instanceof \ DateTime ) ) { throw new UnexpectedValueException ( "min() only wo... | Gets the minimum item value of all items or by invoking a transform function on each item to get a numeric value . |
227,561 | public function concat ( $ second ) { LinqHelper :: assertArgumentIsIterable ( $ second , "second" ) ; $ allItems = new \ ArrayIterator ( [ $ this -> iterator , $ second ] ) ; return new Linq ( new SelectManyIterator ( $ allItems ) ) ; } | Concatenates this Linq object with the given sequence . |
227,562 | public function intersect ( $ second ) { LinqHelper :: assertArgumentIsIterable ( $ second , "second" ) ; return new Linq ( new IntersectIterator ( $ this -> iterator , LinqHelper :: getIteratorOrThrow ( $ second ) ) ) ; } | Intersects the Linq sequence with second Iterable sequence . |
227,563 | public function except ( $ second ) { LinqHelper :: assertArgumentIsIterable ( $ second , "second" ) ; return new Linq ( new ExceptIterator ( $ this -> iterator , LinqHelper :: getIteratorOrThrow ( $ second ) ) ) ; } | Returns all elements except the ones of the given sequence . |
227,564 | protected function filterExtensionsByModuleId ( $ modules , $ moduleId ) { $ modulePaths = \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getConfigParam ( 'aModulePaths' ) ; $ path = '' ; if ( isset ( $ modulePaths [ $ moduleId ] ) ) { $ path = $ modulePaths [ $ moduleId ] . '/' ; } if ( ! $ path ) { $ path... | Returns extensions list by module id . |
227,565 | protected function validate ( ) { if ( ! CommonUtils :: isRegexExpr ( $ this -> pattern ) ) { return false ; } return ( bool ) preg_match ( $ this -> pattern , $ this -> getRequestValue ( ) ) ; } | Execute field name validation |
227,566 | public function metas ( ) { $ model = new \ Kodeine \ Metable \ MetaData ( ) ; $ model -> setTable ( $ this -> getMetaTable ( ) ) ; return new HasMany ( $ model -> newQuery ( ) , $ this , $ this -> getMetaKeyName ( ) , $ this -> getKeyName ( ) ) ; } | Relationship for meta tables |
227,567 | public function setValueAttribute ( $ value ) { $ type = gettype ( $ value ) ; if ( is_array ( $ value ) ) { $ this -> type = 'array' ; $ this -> attributes [ 'value' ] = json_encode ( $ value ) ; } elseif ( $ value instanceof DateTime ) { $ this -> type = 'datetime' ; $ this -> attributes [ 'value' ] = $ this -> fromD... | Set the value and type . |
227,568 | public function getThumbnail ( ) { try { $ ffmpeg = FFMpeg :: create ( ) ; $ video = $ ffmpeg -> open ( $ this -> file -> getPathname ( ) ) ; $ frame = $ video -> frame ( TimeCode :: fromSeconds ( 0 ) ) ; $ base64 = $ frame -> save ( tempnam ( sys_get_temp_dir ( ) , $ this -> file -> getBasename ( ) ) , true , true ) ;... | Generates a thumbnail for the video from the first frame . |
227,569 | public function deleting ( Model $ model ) { $ model -> deleted_by = $ this -> guard -> check ( ) ? $ this -> guard -> user ( ) -> getId ( ) : null ; } | Set deleted_by on the model prior to deletion . |
227,570 | public function getParam ( $ key ) { return isset ( $ this -> params [ $ key ] ) ? $ this -> params [ $ key ] : null ; } | Returns a search parameter by key . |
227,571 | public function hasFilters ( ) { $ params = array_except ( $ this -> params , [ 'order' , 'limit' ] ) ; return ! empty ( $ params ) && ! empty ( array_values ( $ params ) ) ; } | Returns whether the parameters array contains any filters . |
227,572 | public function files ( ) { $ files = [ ] ; foreach ( call_user_func ( $ this -> callable ) as $ file ) { $ path = $ this -> scanner -> find ( $ file ) ; if ( $ path === false ) { throw new RuntimeException ( "Could not locate {$file} for {$this->callable} in any configured path." ) ; } $ files [ ] = new Local ( $ path... | Get the list of files from the callback . |
227,573 | public function input ( $ filename , $ input ) { if ( substr ( $ filename , strlen ( $ this -> _settings [ 'ext' ] ) * - 1 ) !== $ this -> _settings [ 'ext' ] ) { return $ input ; } $ filename = preg_replace ( '/ /' , '\\ ' , $ filename ) ; $ bin = $ this -> _settings [ 'sass' ] . ' ' . $ filename ; $ return = $ this -... | Runs SCSS compiler against any files that match the configured extension . |
227,574 | public function input ( $ filename , $ input ) { if ( substr ( $ filename , strlen ( $ this -> _settings [ 'ext' ] ) * - 1 ) !== $ this -> _settings [ 'ext' ] ) { return $ input ; } $ cmd = $ this -> _settings [ 'node' ] . ' ' . $ this -> _settings [ 'coffee' ] . ' -c -p -s ' ; $ env = array ( 'NODE_PATH' => $ this -> ... | Runs coffee against files that match the configured extension . |
227,575 | public function getParameter ( $ key ) { $ query = $ this -> getQuery ( ) ; return isset ( $ query [ $ key ] ) ? $ query [ $ key ] : null ; } | Returns a query string parameter for a given key . |
227,576 | public function getQuery ( ) { if ( $ this -> query === null ) { $ string = parse_url ( $ this -> link , PHP_URL_QUERY ) ; parse_str ( $ string , $ this -> query ) ; } return $ this -> query ; } | Returns an array of query string parameters in the URL . |
227,577 | public static function assetURL ( array $ params ) { if ( isset ( $ params [ 'asset' ] ) && is_object ( $ params [ 'asset' ] ) ) { $ asset = $ params [ 'asset' ] ; $ params [ 'asset' ] = $ params [ 'asset' ] -> getId ( ) ; } if ( ! isset ( $ params [ 'action' ] ) ) { $ params [ 'action' ] = 'view' ; } if ( isset ( $ pa... | Generate a URL to link to an asset . |
227,578 | public static function chunk ( $ type , $ slotname , $ page = null ) { return ChunkFacade :: insert ( $ type , $ slotname , $ page ) ; } | Interest a chunk into a page . |
227,579 | public static function description ( PageInterface $ page = null ) { $ page = $ page ? : Router :: getActivePage ( ) ; $ description = $ page -> getDescription ( ) ? : ChunkFacade :: get ( 'text' , 'standfirst' , $ page ) -> text ( ) ; return strip_tags ( $ description ) ; } | Reutrn the meta description for a page . |
227,580 | public static function getTags ( ) { $ finder = new Tag \ Finder \ Finder ( ) ; foreach ( func_get_args ( ) as $ arg ) { if ( is_string ( $ arg ) ) { $ finder -> addFilter ( new Tag \ Finder \ Group ( $ arg ) ) ; } elseif ( $ arg instanceof PageInterface ) { $ finder -> addFilter ( new Tag \ Finder \ AppliedToPage ( $ ... | Get tags matching given parameters . Accepts a page group name or tag as arguments in any order to search by . |
227,581 | public static function getTagsInSection ( PageInterface $ page = null , $ group = null ) { $ page = $ page ? : Router :: getActivePage ( ) ; $ finder = new Tag \ Finder \ Finder ( ) ; $ finder -> addFilter ( new Tag \ Finder \ AppliedToPageDescendants ( $ page ) ) ; $ finder -> addFilter ( new Tag \ Finder \ Group ( $ ... | Get the pages applied to the children of a page . |
227,582 | public static function pub ( $ file , $ theme = null ) { $ theme = $ theme ? : static :: activeThemeName ( ) ; return "/vendor/boomcms/themes/$theme/" . ltrim ( trim ( $ file ) , '/' ) ; } | Get a relative path to a file in a theme s public directory . |
227,583 | public function getValue ( array $ keys , $ default = null ) { $ config = $ this -> config ; $ pointer = & $ config ; foreach ( $ keys as $ key ) { if ( ! array_key_exists ( $ key , $ pointer ) ) { if ( $ default === null ) { throw new InvalidArgumentException ( sprintf ( 'Key "%s" does not exist' , implode ( '.' , $ k... | Returns value by key . You can supply default value for when the key is missing . Without default value exception is thrown for nonexistent keys . |
227,584 | public function hasLink ( ) { return isset ( $ this -> attrs [ 'url' ] ) && trim ( $ this -> attrs [ 'url' ] ) && $ this -> attrs [ 'url' ] !== '#' && $ this -> attrs [ 'url' ] !== 'http://' ; } | Whether the current slide has a link associated with it . |
227,585 | public function isFresh ( AssetTarget $ target ) { $ buildName = $ this -> buildFileName ( $ target ) ; $ buildFile = $ this -> outputDir ( $ target ) . DIRECTORY_SEPARATOR . $ buildName ; if ( ! file_exists ( $ buildFile ) ) { return false ; } $ buildTime = filemtime ( $ buildFile ) ; if ( $ this -> configTime && $ th... | Check to see if a cached build file is fresh . Fresh cached files have timestamps newer than all of the component files . |
227,586 | public function buildFileName ( AssetTarget $ target ) { $ file = $ target -> name ( ) ; if ( $ target -> isThemed ( ) && $ this -> theme ) { $ file = $ this -> theme . '-' . $ file ; } return $ file ; } | Get the final build file name for a target . |
227,587 | public function read ( AssetTarget $ target ) { $ buildName = $ this -> buildFileName ( $ target ) ; return file_get_contents ( $ this -> path . $ buildName ) ; } | Get the cached result for a build target . |
227,588 | public function settings ( array $ settings = null ) { if ( $ settings ) { $ this -> _settings = array_merge ( $ this -> _settings , $ settings ) ; } return $ this -> _settings ; } | Gets settings for this filter . Will always include paths key which points at paths available for the type of asset being generated . |
227,589 | protected function _runCmd ( $ cmd , $ content , $ environment = null ) { $ Process = new AssetProcess ( ) ; $ Process -> environment ( $ environment ) ; $ Process -> command ( $ cmd ) -> run ( $ content ) ; if ( $ Process -> error ( ) ) { throw new RuntimeException ( $ Process -> error ( ) ) ; } return $ Process -> ou... | Run the compressor command and get the output |
227,590 | protected function _query ( $ content , $ args = array ( ) ) { if ( ! extension_loaded ( 'curl' ) ) { throw new \ Exception ( 'Missing the `curl` extension.' ) ; } $ args = array_merge ( $ this -> _defaults , $ args ) ; if ( ! empty ( $ this -> _settings [ 'level' ] ) ) { $ args [ 'compilation_level' ] = $ this -> _set... | Query the Closure compiler API . |
227,591 | public function writer ( $ tmpPath = '' ) { $ tmpPath = $ tmpPath ? : $ this -> config -> get ( 'general.timestampPath' ) ; if ( ! $ tmpPath ) { $ tmpPath = sys_get_temp_dir ( ) . DIRECTORY_SEPARATOR ; } $ timestamp = [ 'js' => $ this -> config -> get ( 'js.timestamp' ) , 'css' => $ this -> config -> get ( 'css.timesta... | Create an AssetWriter |
227,592 | public function cacher ( $ path = '' ) { if ( ! $ path ) { $ path = sys_get_temp_dir ( ) . DIRECTORY_SEPARATOR ; } $ cache = new AssetCacher ( $ path , $ this -> config -> theme ( ) ) ; $ cache -> configTimestamp ( $ this -> config -> modifiedTime ( ) ) ; $ cache -> filterRegistry ( $ this -> filterRegistry ( ) ) ; ret... | Create an AssetCacher |
227,593 | public function target ( $ name ) { if ( ! $ this -> config -> hasTarget ( $ name ) ) { throw new RuntimeException ( "The target named '$name' does not exist." ) ; } $ ext = $ this -> config -> getExt ( $ name ) ; $ themed = $ this -> config -> isThemed ( $ name ) ; $ filters = $ this -> config -> targetFilters ( $ nam... | Create a single build target |
227,594 | public function filterRegistry ( ) { $ filters = [ ] ; foreach ( $ this -> config -> allFilters ( ) as $ name ) { $ filters [ $ name ] = $ this -> buildFilter ( $ name , $ this -> config -> filterConfig ( $ name ) ) ; } return new FilterRegistry ( $ filters ) ; } | Create a filter registry containing all the configured filters . |
227,595 | public function getNext ( ) { return $ this -> where ( self :: ATTR_PAGE , $ this -> getPageId ( ) ) -> where ( self :: ATTR_CREATED_AT , '>' , $ this -> getEditedTime ( ) -> getTimestamp ( ) ) -> orderBy ( self :: ATTR_CREATED_AT , 'asc' ) -> first ( ) ; } | Returns the next version . |
227,596 | public function isPublished ( DateTime $ time = null ) { $ timestamp = $ time ? $ time -> getTimestamp ( ) : time ( ) ; return $ this -> { self :: ATTR_EMBARGOED_UNTIL } && $ this -> { self :: ATTR_EMBARGOED_UNTIL } <= $ timestamp ; } | Whether the version is published . |
227,597 | public function status ( DateTime $ time = null ) { if ( $ this -> isPendingApproval ( ) ) { return 'pending approval' ; } elseif ( $ this -> isDraft ( ) ) { return 'draft' ; } elseif ( $ this -> isPublished ( $ time ) ) { return 'published' ; } elseif ( $ this -> isEmbargoed ( $ time ) ) { return 'embargoed' ; } } | Returns the status of the current page version . |
227,598 | public function addRole ( $ roleId , $ allowed , $ pageId = 0 ) { if ( ! $ this -> hasRole ( $ roleId , $ pageId ) ) { $ this -> roles ( ) -> attach ( $ roleId , [ self :: PIVOT_ATTR_ALLOWED => $ allowed , self :: PIVOT_ATTR_PAGE_ID => $ pageId , ] ) ; } return $ this ; } | Adds a role to the current group . |
227,599 | public function removeRole ( $ roleId , $ pageId = 0 ) { $ this -> roles ( ) -> wherePivot ( self :: PIVOT_ATTR_ROLE_ID , '=' , $ roleId ) -> wherePivot ( self :: PIVOT_ATTR_PAGE_ID , '=' , $ pageId ) -> detach ( ) ; return $ this ; } | Remove a role from a group . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.