idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
9,500 | public function where ( $ column , $ expression = null , $ value = null ) { return $ this -> doWhere ( self :: AND_WHERE , $ column , $ expression , $ value ) ; } | Add a where clause to the query . |
9,501 | public function andWhereIn ( $ column , array $ values ) { $ this -> where [ ] = [ self :: AND_WHERE_IN , $ column , $ values ] ; return $ this ; } | Add an and where in clause to the query . |
9,502 | public function orWhereIn ( $ column , array $ values ) { $ this -> where [ ] = [ self :: OR_WHERE_IN , $ column , $ values ] ; return $ this ; } | Add an or where in clause to the query . |
9,503 | public function on ( $ event_name , $ handler_callback ) { $ event = null ; if ( ! isset ( $ this -> event_queue [ $ event_name ] ) ) { $ event = new Event ( $ event_name ) ; $ this -> event_queue [ $ event_name ] = $ event ; } $ event = $ this -> event_queue [ $ event_name ] ; $ event -> setHandlerCallback ( $ handler... | add a callback to the event one event one handler callback the handler callback is swappable so later handler callback can override previous handler callback |
9,504 | public function trigger ( $ event_name , $ default_handler_callback = "" , $ event_properties = array ( ) ) { $ event = null ; if ( isset ( $ this -> event_queue [ $ event_name ] ) ) { $ event = $ this -> event_queue [ $ event_name ] ; $ event -> setProperties ( $ event_properties ) ; $ handler_callback = $ event -> ge... | trigger an event with a default handler callback |
9,505 | public function usePlugin ( $ plugin_name , $ config = array ( ) ) { if ( ! isset ( $ this -> plugins [ $ plugin_name ] ) ) { $ plugin_name = str_replace ( "." , "\\" , $ plugin_name ) ; $ plugin_class_name = $ plugin_name . "\Main" ; $ this -> plugins [ $ plugin_name ] = new $ plugin_class_name ( ) ; $ this -> plugins... | tell the sytem to use a plugin |
9,506 | public function loadAllPlugins ( ) { if ( count ( $ this -> plugins ) > 0 ) { foreach ( $ this -> plugins as $ plugin_name => $ plugin ) { $ event_helpers = $ plugin -> getEventHelperCallbacks ( ) ; if ( count ( $ event_helpers ) > 0 ) { foreach ( $ event_helpers as $ event_name => $ callback ) { if ( ! isset ( $ this ... | load all plugins |
9,507 | public function findByLocale ( $ id , $ locale ) { return $ this -> model -> with ( [ 'type' , 'contents' => function ( $ query ) { $ query -> with ( 'lang' ) ; } ] ) -> where ( 'id' , $ id ) -> first ( ) ; } | find model by locale |
9,508 | public function store ( array $ data ) { DB :: transaction ( function ( ) use ( $ data ) { $ model = $ this -> storeNotificationInstance ( $ data ) ; foreach ( $ data [ 'title' ] as $ langId => $ content ) { $ model -> contents ( ) -> save ( $ model -> contents ( ) -> getModel ( ) -> newInstance ( [ 'notification_id' =... | stores new notification |
9,509 | protected function storeNotificationInstance ( array $ data ) { is_null ( $ typeId = array_get ( $ data , 'type_id' ) ) ? $ typeId = app ( NotificationTypes :: class ) -> where ( 'name' , array_get ( $ data , 'type' ) ) -> first ( ) -> id : null ; $ model = $ this -> model -> getModel ( ) -> newInstance ( [ 'category_i... | Stores notification instance details |
9,510 | public function sync ( array $ data , array $ areas = [ ] ) { DB :: beginTransaction ( ) ; try { $ templates = array_get ( $ data , 'templates' , [ ] ) ; $ model = $ this -> storeNotificationInstance ( $ data ) ; $ langs = array_get ( $ data , 'languages' , [ ] ) ; foreach ( $ langs as $ lang ) { $ this -> processSingl... | Stores system notifications |
9,511 | protected function processSingle ( array $ data , $ lang , $ model ) { is_null ( $ view = array_get ( $ data , 'templates.' . $ lang -> code ) ) ? $ view = array_get ( $ data , 'templates.' . $ lang -> code ) : null ; $ content = '' ; if ( is_null ( $ view ) ) { $ content = app ( $ data [ 'classname' ] ) -> render ( ) ... | Process signle notification |
9,512 | public function getNotificationContents ( $ type = null ) { return NotificationContents :: select ( [ 'title' , 'id' ] ) -> whereHas ( 'lang' , function ( $ query ) { $ query -> where ( 'code' , locale ( ) ) ; } ) -> whereHas ( 'notification' , function ( $ query ) use ( $ type ) { if ( is_null ( $ type ) ) { $ query -... | Gets notification contents |
9,513 | public function mapObjectsToRows ( $ objects , $ meta = null , $ context = null ) { if ( ! $ objects ) { return [ ] ; } if ( ! $ meta instanceof Meta ) { $ meta = $ this -> getMeta ( $ meta ? : get_class ( current ( $ objects ) ) ) ; } $ out = [ ] ; foreach ( $ objects as $ key => $ object ) { $ out [ $ key ] = $ this ... | Get row values from a list of objects |
9,514 | public function createObject ( $ meta , $ mapped , $ args = null ) { if ( ! $ meta instanceof Meta ) { $ meta = $ this -> getMeta ( $ meta ) ; } $ object = null ; $ args = $ args ? array_values ( $ args ) : [ ] ; $ argc = $ args ? count ( $ args ) : 0 ; if ( $ meta -> constructorArgs ) { $ actualArgs = [ ] ; foreach ( ... | The row is made available to this function but this is so it can be used to construct the object not to populate it . Feel free to ignore it it will be passed to populateObject as well . |
9,515 | public function populateObject ( $ object , \ stdClass $ mapped , $ meta = null ) { if ( ! $ meta instanceof Meta ) { $ meta = $ this -> getMeta ( $ meta ? : get_class ( $ object ) ) ; if ( ! $ meta ) { throw new \ InvalidArgumentException ( ) ; } } $ properties = $ meta -> getProperties ( ) ; foreach ( $ mapped as $ p... | Populate an object with row values |
9,516 | public function addData ( array $ data ) : ErrorResponseBuilder { $ this -> data = array_merge ( $ this -> data , $ data ) ; return $ this ; } | Add additonal data appended to the error object . |
9,517 | public function setError ( $ errorCode = null , $ message = null ) : ErrorResponseBuilder { $ this -> errorCode = $ errorCode ; if ( is_array ( $ message ) ) { $ this -> parameters = $ message ; } else { $ this -> message = $ message ; } return $ this ; } | Set the error code and optionally an error message . |
9,518 | public function setStatus ( int $ statusCode ) : ResponseBuilder { if ( $ statusCode < 400 || $ statusCode >= 600 ) { throw new InvalidArgumentException ( "{$statusCode} is not a valid error HTTP status code." ) ; } return parent :: setStatus ( $ statusCode ) ; } | Set the HTTP status code for the response . |
9,519 | protected function buildErrorData ( ) { if ( is_null ( $ this -> errorCode ) ) { return null ; } $ data = [ 'code' => $ this -> errorCode , 'message' => $ this -> message ? : $ this -> resolveMessage ( ) ] ; return array_merge ( $ data , $ this -> data ) ; } | Build the error object of the serialized response data . |
9,520 | protected function resolveMessage ( ) { if ( ! $ this -> translator -> has ( $ code = "errors.$this->errorCode" ) ) { return null ; } return $ this -> translator -> trans ( $ code , $ this -> parameters ) ; } | Resolve an error message from the translator . |
9,521 | public function ensureIlluminateBase ( Container $ app = null ) { if ( ! $ app -> bound ( 'events' ) ) { $ app -> singleton ( 'events' , $ this -> illuminateClasses [ 'events' ] ) ; $ app [ 'events' ] -> fire ( 'booting' ) ; } if ( ! $ app -> bound ( 'files' ) ) { $ app -> bindIf ( 'files' , $ this -> illuminateClasses... | Ensure the base event and file bindings are present . Required for binding anything else . |
9,522 | public function bindIlluminateCore ( Container $ app = null ) { if ( ! $ app ) { $ app = new Container ( ) ; } $ this -> ensureIlluminateBase ( $ app ) ; $ app -> bindIf ( 'url' , $ this -> illuminateClasses [ 'url' ] ) ; $ app -> bindIf ( 'session.manager' , function ( $ app ) { return new SessionManager ( $ app ) ; }... | Bind the core classes to the Container |
9,523 | protected function loadIlluminateConfig ( Container $ app , Repository $ config ) { foreach ( $ this -> getIlluminateConfig ( $ app ) as $ key => $ path ) { $ config -> set ( $ key , require $ path ) ; } } | Load the configuration items from all config files . |
9,524 | protected function getIlluminateConfig ( Container $ app ) { $ files = array ( ) ; foreach ( Finder :: create ( ) -> files ( ) -> name ( '*.php' ) -> in ( $ app [ 'path.config' ] ) as $ file ) { $ files [ basename ( $ file -> getRealPath ( ) , '.php' ) ] = $ file -> getRealPath ( ) ; } return $ files ; } | Get all configuration files from the application . |
9,525 | public function findOne ( $ conditions , string $ orderBy = null ) : Result { $ query = $ this -> query ( ) -> where ( $ conditions ) -> limit ( 1 ) ; if ( $ orderBy ) { $ query -> orderBy ( $ orderBy ) ; } return $ query -> query ( ) ; } | Builds the query for the given conditions and executes it Will return an result with 1 or 0 rows |
9,526 | public function validateIdentifier ( $ id ) { $ printed = print_r ( $ id , true ) ; if ( count ( $ this -> keys ) > 1 && ! is_array ( $ id ) ) { throw new \ RuntimeException ( "Entity $this->name has a composed key, finding by id requires an array, given: $printed" ) ; } if ( count ( $ this -> keys ) !== count ( $ id )... | Validates the identifier to prevent unexpected behaviour |
9,527 | public function where ( $ id ) { $ this -> validateIdentifier ( $ id ) ; if ( ! is_array ( $ id ) ) { $ key = reset ( $ this -> keys ) ; return [ $ key => $ id ] ; } else { return $ id ; } } | Creates the where condition for the identifier |
9,528 | private function handleRunningProcess ( Process $ process , & $ runningCommand , & $ failed , & $ hasReceivedSignal , & $ exitCode , & $ exitCodeText ) { if ( $ process -> isRunning ( ) ) { if ( $ hasReceivedSignal ) { return ; } if ( $ this -> shutdownNow ) { $ this -> output -> write ( "[RECEIVED SIGNAL] Shutting dow... | Handles any running process waiting for signals .. |
9,529 | public function addFixture ( FixtureInterface $ fixture ) { $ this -> dropTables = array_merge ( $ this -> dropTables , ( array ) $ fixture -> getTables ( ) ) ; $ this -> fixtures [ ] = $ fixture ; } | Add a fixture to be loaded into the database . |
9,530 | public function run ( Connection $ connection , $ append = false ) { if ( ! $ append ) { foreach ( array_unique ( $ this -> dropTables ) as $ table ) { $ connection -> delete ( $ table , [ 1 => 1 ] , [ \ PDO :: PARAM_INT ] ) ; } } foreach ( $ this -> getSortedFixtures ( ) as $ fixture ) { $ this -> runFixture ( $ conne... | Run all fixtures . |
9,531 | public function each ( callable $ closure ) { $ results = [ ] ; foreach ( $ this -> rows as $ row ) { $ results [ ] = $ closure ( ... array_values ( $ row ) ) ; } return $ results ; } | Call a closure for each row |
9,532 | public function row ( ) { if ( isset ( $ this -> rows [ $ this -> cursor ] ) ) { return $ this -> rows [ $ this -> cursor ++ ] ; } return false ; } | Get a single row as array |
9,533 | public function containsResourceIdentifier ( $ resourceIdentifier ) { $ items = $ this -> getItems ( 0 , false ) ; foreach ( $ items [ 0 ] as $ item ) { if ( $ item -> _id = $ resourceIdentifier ) { return true ; } } return false ; } | Test to see if the given resource identifier exists in the collection of resources . |
9,534 | protected function createCollectionResourceForItems ( $ items , $ from , $ to , $ count ) { $ resource = parent :: get ( ) ; $ resource -> items = $ items ; $ resource -> count = $ count ; $ resource -> range = new \ stdClass ( ) ; $ resource -> range -> from = $ from ; $ resource -> range -> to = $ to ; return $ resou... | Creates a valid collection response from a list of objects . |
9,535 | public function attr ( array $ attributes ) { $ result = '' ; foreach ( $ attributes as $ attribute => $ value ) { $ result .= ' ' . ( is_int ( $ attribute ) ? $ value : $ attribute . '="' . str_replace ( '"' , '"' , $ value ) . '"' ) ; } return $ result ; } | Render the attributes |
9,536 | public function mergeAttr ( ) { $ arrays = func_get_args ( ) ; $ result = array ( ) ; foreach ( $ arrays as $ array ) { $ result = $ this -> mergeRecursive ( $ result , $ array ) ; } return $ result ; } | It will merge multiple attributes arrays without erase values |
9,537 | public function insert ( $ substring , $ index ) { if ( $ index <= 0 ) { return $ this -> prepend ( $ substring ) ; } if ( $ index > $ this -> length ( ) ) { return $ this -> append ( $ substring ) ; } $ start = mb_substr ( $ this -> string , 0 , $ index , $ this -> encoding ) ; $ end = mb_substr ( $ this -> string , $... | Inserts a substring at the given index |
9,538 | public function compare ( $ compare , callable $ callback = null ) { if ( $ callback === null ) { $ callback = 'strcmp' ; } return $ callback ( $ this -> string , ( string ) $ compare ) ; } | Compares this string to another |
9,539 | public function slice ( $ offset , $ length = null ) { $ offset = $ this -> prepareOffset ( $ offset ) ; $ length = $ this -> prepareLength ( $ offset , $ length ) ; if ( $ length === 0 ) { return new Text ( '' , $ this -> encoding ) ; } return new Text ( mb_substr ( $ this -> string , $ offset , $ length , $ this -> e... | Slices a piece of the string from a given offset with a specified length . If no length is given the String is sliced to its maximum length . |
9,540 | public function substring ( $ start , $ end = null ) { $ length = $ this -> length ( ) ; if ( $ end < 0 ) { $ end = $ length + $ end ; } $ end = $ end !== null ? min ( $ end , $ length ) : $ length ; $ start = min ( $ start , $ end ) ; $ end = max ( $ start , $ end ) ; $ end = $ end - $ start ; return new Text ( mb_sub... | Slices a piece of the string from a given start to an end . If no length is given the String is sliced to its maximum length . |
9,541 | public function countSubstring ( $ substring , $ caseSensitive = true ) { $ this -> verifyNotEmpty ( $ substring , '$substring' ) ; if ( $ caseSensitive ) { return mb_substr_count ( $ this -> string , $ substring , $ this -> encoding ) ; } $ str = mb_strtoupper ( $ this -> string , $ this -> encoding ) ; $ substring = ... | Count the number of substring occurrences . |
9,542 | public function supplant ( array $ map ) { return new Text ( str_replace ( array_keys ( $ map ) , array_values ( $ map ) , $ this -> string ) , $ this -> encoding ) ; } | Replaces all occurences of given replacement map . Keys will be replaced with its values . |
9,543 | public function splice ( $ replacement , $ offset , $ length = null ) { $ offset = $ this -> prepareOffset ( $ offset ) ; $ length = $ this -> prepareLength ( $ offset , $ length ) ; $ start = $ this -> substring ( 0 , $ offset ) ; $ end = $ this -> substring ( $ offset + $ length ) ; return new Text ( $ start . $ repl... | Replace text within a portion of a string . |
9,544 | public function chars ( ) { $ chars = new ArrayObject ( ) ; for ( $ i = 0 , $ l = $ this -> length ( ) ; $ i < $ l ; $ i ++ ) { $ chars -> push ( $ this -> at ( $ i ) ) ; } return $ chars ; } | Returns an ArrayObject consisting of the characters in the string . |
9,545 | public function indexOf ( $ string , $ offset = 0 ) { $ offset = $ this -> prepareOffset ( $ offset ) ; if ( $ string == '' ) { return $ offset ; } return mb_strpos ( $ this -> string , ( string ) $ string , $ offset , $ this -> encoding ) ; } | Returns the index of a given string starting at the optional zero - related offset |
9,546 | public function lastIndexOf ( $ string , $ offset = null ) { if ( null === $ offset ) { $ offset = $ this -> length ( ) ; } else { $ offset = $ this -> prepareOffset ( $ offset ) ; } if ( $ string === '' ) { return $ offset ; } return mb_strrpos ( $ this , ( string ) $ string , $ offset - $ this -> length ( ) , $ this ... | Returns the last index of a given string starting at the optional offset |
9,547 | public function startsWith ( $ substring ) { $ substringLength = mb_strlen ( $ substring , $ this -> encoding ) ; $ startOfStr = mb_substr ( $ this -> string , 0 , $ substringLength , $ this -> encoding ) ; return ( string ) $ substring === $ startOfStr ; } | Checks whether the string starts with the given string . Case sensitive! |
9,548 | public function startsWithIgnoreCase ( $ substring ) { $ substring = mb_strtolower ( $ substring , $ this -> encoding ) ; $ substringLength = mb_strlen ( $ substring , $ this -> encoding ) ; $ startOfStr = mb_strtolower ( mb_substr ( $ this -> string , 0 , $ substringLength , $ this -> encoding ) ) ; return ( string ) ... | Checks whether the string starts with the given string . Ignores case . |
9,549 | public function endsWith ( $ substring ) { $ substringLength = mb_strlen ( $ substring , $ this -> encoding ) ; $ endOfStr = mb_substr ( $ this -> string , $ this -> length ( ) - $ substringLength , $ substringLength , $ this -> encoding ) ; return ( string ) $ substring === $ endOfStr ; } | Checks whether the string ends with the given string . Case sensitive! |
9,550 | public function endsWithIgnoreCase ( $ substring ) { $ substring = mb_strtolower ( $ substring , $ this -> encoding ) ; $ substringLength = mb_strlen ( $ substring , $ this -> encoding ) ; $ endOfStr = mb_strtolower ( mb_substr ( $ this -> string , $ this -> length ( ) - $ substringLength , $ substringLength , $ this -... | Checks whether the string ends with the given string . Ingores case . |
9,551 | public function pad ( $ length , $ padding = ' ' ) { $ len = $ length - $ this -> length ( ) ; return $ this -> applyPadding ( floor ( $ len / 2 ) , ceil ( $ len / 2 ) , $ padding ) ; } | Adds padding to the start and end |
9,552 | public function wrapWords ( $ width = 75 , $ break = "\n" , $ cut = false ) { return new Text ( wordwrap ( $ this -> string , $ width , $ break , $ cut ) , $ this -> encoding ) ; } | Returns a copy of the string wrapped at a given number of characters |
9,553 | public function truncate ( $ length , $ substring = '' ) { if ( $ this -> length ( ) <= $ length ) { return new Text ( $ this -> string , $ this -> encoding ) ; } $ substrLen = mb_strlen ( $ substring , $ this -> encoding ) ; if ( $ this -> length ( ) + $ substrLen > $ length ) { $ length -= $ substrLen ; } return $ th... | Truncates the string with a substring and ensures it doesn t exceed the given length |
9,554 | public function split ( $ delimiter , $ limit = PHP_INT_MAX ) { return new ArrayObject ( explode ( $ delimiter , $ this -> string , $ limit ) ) ; } | Splits the string by string |
9,555 | public static function join ( array $ pieces , $ glue = '' , $ encoding = null ) { return new Text ( implode ( $ pieces , $ glue ) , $ encoding ) ; } | Join array elements with a string |
9,556 | public function chunk ( $ splitLength = 1 ) { $ this -> verifyPositive ( $ splitLength , 'The chunk length' ) ; return new ArrayObject ( str_split ( $ this -> string , $ splitLength ) ) ; } | Convert the string to an array |
9,557 | public function toLowerCaseFirst ( ) { $ first = $ this -> substring ( 0 , 1 ) ; $ rest = $ this -> substring ( 1 ) ; return new Text ( mb_strtolower ( $ first , $ this -> encoding ) . $ rest , $ this -> encoding ) ; } | Transforms the string to first character lowercased |
9,558 | public function toUpperCaseFirst ( ) { $ first = $ this -> substring ( 0 , 1 ) ; $ rest = $ this -> substring ( 1 ) ; return new Text ( mb_strtoupper ( $ first , $ this -> encoding ) . $ rest , $ this -> encoding ) ; } | Transforms the string to first character uppercased |
9,559 | public function toCapitalCaseWords ( ) { $ encoding = $ this -> encoding ; return $ this -> split ( ' ' ) -> map ( function ( $ str ) use ( $ encoding ) { return Text :: create ( $ str , $ encoding ) -> toCapitalCase ( ) ; } ) -> join ( ' ' ) ; } | Transforms the string with the words capitalized . |
9,560 | public function toStudlyCase ( ) { $ input = $ this -> trim ( '-_' ) ; if ( $ input -> isEmpty ( ) ) { return $ input ; } $ encoding = $ this -> encoding ; return Text :: create ( preg_replace_callback ( '/([A-Z-_][a-z0-9]+)/' , function ( $ matches ) use ( $ encoding ) { return Text :: create ( $ matches [ 0 ] , $ enc... | Converts this string into StudlyCase . Numbers are considered as part of its previous piece . |
9,561 | public function toKebabCase ( ) { if ( $ this -> contains ( '_' ) ) { return $ this -> replace ( '_' , '-' ) ; } return new Text ( mb_strtolower ( preg_replace ( '/([a-z0-9])([A-Z])/' , '$1-$2' , $ this -> string ) ) , $ this -> encoding ) ; } | Convert this string into kebab - case . Numbers are considered as part of its previous piece . |
9,562 | public function toPlural ( Pluralizer $ pluralizer = null ) { $ pluralizer = $ pluralizer ? : new EnglishPluralizer ( ) ; return new Text ( $ pluralizer -> getPluralForm ( $ this -> string ) , $ this -> encoding ) ; } | Get the plural form of the Text object . |
9,563 | public function toSingular ( Pluralizer $ pluralizer = null ) { $ pluralizer = $ pluralizer ? : new EnglishPluralizer ( ) ; return new Text ( $ pluralizer -> getSingularForm ( $ this -> string ) , $ this -> encoding ) ; } | Get the singular form of the Text object . |
9,564 | public static function isUsed ( $ password , $ user = null ) { if ( ! User :: isValid ( $ user ) ) { throw new InvalidParamException ( 'User Invalid.' ) ; } $ passwords = static :: find ( ) -> createdBy ( $ user ) -> all ( ) ; foreach ( $ passwords as $ p ) { if ( $ p -> validatePassword ( $ password ) ) { return $ p ;... | Check whether the password has been used . |
9,565 | public static function add ( $ password , $ user = null ) { if ( static :: isUsed ( $ password , $ user ) && ! $ user -> allowUsedPassword ) { throw new InvalidParamException ( 'Password existed.' ) ; } if ( static :: judgePasswordHash ( $ password ) ) { $ passwordHistory = $ user -> create ( static :: class ) ; $ pass... | Add password to history . |
9,566 | public static function first ( $ user = null ) { if ( ! User :: isValid ( $ user ) ) { throw new InvalidParamException ( 'User Invalid.' ) ; } return static :: find ( ) -> createdBy ( $ user ) -> orderByCreatedAt ( ) -> one ( ) ; } | Get first password hash . |
9,567 | public static function last ( $ user = null ) { if ( ! User :: isValid ( $ user ) ) { throw new InvalidParamException ( 'User Invalid.' ) ; } return static :: find ( ) -> createdBy ( $ user ) -> orderByCreatedAt ( SORT_DESC ) -> one ( ) ; } | Get last password hash . |
9,568 | public function getScript ( ) { $ this -> useSingleQuotes ( ) ; foreach ( $ this -> aArguments as $ xArgument ) { if ( $ xArgument instanceof Element ) { $ this -> addParameter ( Jaxon :: JS_VALUE , $ xArgument -> getScript ( ) ) ; } else if ( $ xArgument instanceof Parameter ) { $ this -> addParameter ( $ xArgument ->... | Return a string representation of the call to this jQuery function |
9,569 | public function parseBody ( $ origLine ) { $ line = rtrim ( $ origLine , "\r\n" ) ; if ( $ this -> parserState == self :: PARSE_STATE_HEADERS && $ line == '' ) { $ this -> parserState = self :: PARSE_STATE_BODY ; $ headers = new ezcMailHeadersHolder ( ) ; $ headers [ 'Content-Type' ] = $ this -> headers [ 'Content-Type... | Parses the body of an rfc 2822 message . |
9,570 | public function saveHtml ( $ filename , $ base = null ) { $ this -> ensureWritableDirectory ( dirname ( $ filename ) ) ; $ html = new Html ( $ this -> getHtml ( ) ) ; if ( null !== $ base ) { $ html -> resolveLinks ( \ GuzzleHttp \ Psr7 \ uri_for ( $ base ) ) ; } file_put_contents ( $ filename , $ html -> get ( ) ) ; r... | Save the HTML of the session into a file Optionally resolve all the links with a base uri |
9,571 | public static function parse ( $ filename , $ del = "." ) { if ( is_null ( self :: $ _instance ) ) { self :: $ _instance = new self ( $ filename , $ del ) ; } return self :: $ _instance -> getObj ( ) ; } | Singleton pattern constructor |
9,572 | private function _parseIni ( $ iniFile ) { $ aParsedIni = parse_ini_file ( $ iniFile , true , INI_SCANNER_RAW ) ; $ tmpArray = array ( ) ; foreach ( $ aParsedIni as $ key => $ value ) { if ( strpos ( $ key , ':' ) !== false ) { $ sections = explode ( ':' , $ key ) ; if ( count ( $ sections ) != 2 ) { throw new Exceptio... | Parses ini file and extract its keys and prepare it for object creation |
9,573 | public function trim ( $ file , $ max_w , $ max_h , $ crop = false , $ suffix = null , $ dest_path = null , $ jpeg_quality = 90 ) { $ editor = wp_get_image_editor ( $ file ) ; if ( is_wp_error ( $ editor ) ) return $ editor ; $ editor -> set_quality ( $ jpeg_quality ) ; $ resized = $ editor -> resize ( $ max_w , $ max_... | Clone of image resize |
9,574 | public function fit ( $ src , $ dest , $ width , $ height ) { $ size = getimagesize ( $ src ) ; $ ratio = max ( $ width / $ size [ 0 ] , $ height / $ size [ 1 ] ) ; $ old_width = $ size [ 0 ] ; $ old_height = $ size [ 1 ] ; $ new_width = intval ( $ old_width * $ ratio ) ; $ new_height = intval ( $ old_height * $ ratio ... | Fit small image to specified bound |
9,575 | private function retrieveFormFieldDescription ( AdminInterface $ admin , $ field ) { $ admin -> getFormFieldDescriptions ( ) ; $ fieldDescription = $ admin -> getFormFieldDescription ( $ field ) ; if ( ! $ fieldDescription ) { throw new \ RuntimeException ( sprintf ( 'The field "%s" does not exist.' , $ field ) ) ; } i... | Retrieve the form field description given by field name . Copied from Sonata \ AdminBundle \ Controller \ HelperController . |
9,576 | protected function execute ( InputInterface $ input , OutputInterface $ output ) { $ this -> initialiseWorker ( $ input , $ output ) ; $ totalTasks = $ input -> getOption ( 'total-tasks' ) ; for ( $ counter = 0 ; $ counter < $ totalTasks ; $ counter ++ ) { $ task = new ExampleTaskDescription ( ) ; $ task -> message = '... | Adds an example task to the task queue using the ExampleTask . php |
9,577 | public function read ( $ path ) { $ config = $ this -> readByFilename ( $ path , Visithor :: CONFIG_FILE_NAME_DISTR ) ; if ( false === $ config ) { $ config = $ this -> readByFilename ( $ path , Visithor :: CONFIG_FILE_NAME ) ; } return $ config ; } | Read all the configuration given a path |
9,578 | public function readByFilename ( $ path , $ filename ) { $ config = false ; $ configFilePath = rtrim ( $ path , '/' ) . '/' . $ filename ; if ( is_file ( $ configFilePath ) ) { $ yamlParser = new YamlParser ( ) ; $ config = $ yamlParser -> parse ( file_get_contents ( $ configFilePath ) ) ; } return $ config ; } | Read all the configuration given a path and a filename |
9,579 | public function addClass ( $ class , $ extends = null , $ implements = [ ] ) { $ classId = $ this -> registerClass ( $ class ) ; if ( $ extends ) { $ parentClassId = $ this -> registerClass ( $ extends ) ; $ this -> extends [ $ classId ] = [ $ parentClassId ] ; } if ( ! empty ( $ implements ) ) { $ interfaceIds = [ ] ;... | add class to hierarchy tree |
9,580 | public function addInterface ( $ interface , $ extends = [ ] ) { $ interfaceId = $ this -> registerInterface ( $ interface ) ; if ( ! empty ( $ extends ) ) { $ interfaceIds = [ ] ; foreach ( $ extends as $ name ) { $ interfaceIds [ ] = $ this -> registerInterface ( $ name ) ; } $ this -> interfaceExtends [ $ interfaceI... | add interface to hierarchy tree |
9,581 | public function getParent ( $ class ) { $ classId = $ this -> getClassId ( $ class ) ; if ( ! isset ( $ classId ) ) { return false ; } $ parentClassId = $ this -> extends [ $ classId ] ; return isset ( $ parentClassId ) ? $ this -> classes [ $ parentClassId [ 0 ] ] : null ; } | gets parent class |
9,582 | public function getAncestors ( $ class ) { $ ancestors = [ ] ; while ( true ) { $ parent = $ this -> getParent ( $ class ) ; if ( $ parent ) { $ ancestors [ ] = $ parent ; $ class = $ parent ; } else { break ; } } return $ ancestors ; } | gets all parent classes |
9,583 | public function getImplements ( $ class ) { $ interfaces = [ ] ; $ classId = $ this -> getClassId ( $ class ) ; if ( isset ( $ classId ) ) { if ( isset ( $ this -> implements [ $ classId ] ) ) { foreach ( $ this -> implements [ $ classId ] as $ interfaceId ) { $ interfaces [ $ this -> interfaces [ $ interfaceId ] ] = 1... | gets implemented interfaces |
9,584 | public function isA ( $ class , $ test_class ) { $ test_class = $ this -> normalize ( $ test_class ) ; if ( $ this -> classExists ( $ test_class ) ) { return in_array ( $ test_class , $ this -> getAncestors ( $ class ) ) ; } elseif ( $ this -> interfaceExists ( $ test_class ) ) { return in_array ( $ test_class , $ this... | checks the class is subclass or implements the test class |
9,585 | public function getSubClasses ( $ class ) { $ class = $ this -> normalize ( $ class ) ; if ( $ this -> classExists ( $ class ) ) { return $ this -> getSubclassOfClass ( $ class ) ; } elseif ( $ this -> interfaceExists ( $ class ) ) { return $ this -> getSubclassOfInterface ( $ class ) ; } else { throw new ClassNotExist... | gets all subclass of the class or interface |
9,586 | public function paginate ( ) { $ this -> count = $ this -> query -> get ( ) -> count ( ) ; $ this -> limit = $ this -> limit ? : $ this -> count ; $ this -> query -> skip ( $ this -> offset ) -> take ( $ this -> limit ) ; } | Will modify a query builder to get paginated data and will return an array with the meta data . |
9,587 | public function getNextPageParams ( ) { $ limit = $ this -> limit <= 0 ? $ this -> count : $ this -> limit ; $ next_url = $ this -> offset_key . $ this -> offset . $ this -> limit_key . $ limit ; if ( $ this -> count <= ( $ this -> offset + $ limit ) ) { return false ; } if ( $ this -> count >= $ limit ) { $ next_url =... | Generate the next page url parameters as string . |
9,588 | public function getPrevPageParams ( ) { $ limit = $ this -> limit <= 0 ? $ this -> count : $ this -> limit ; $ prev_url = $ this -> offset_key . $ this -> offset . $ this -> limit_key . $ limit ; if ( $ this -> count >= $ limit ) { $ prev_url = $ this -> offset_key . ( $ this -> offset - $ limit ) . $ this -> limit_key... | Generate the prev page url parameters as string . |
9,589 | public function getLastPageParams ( ) { $ limit = $ this -> limit <= 0 ? $ this -> count : $ this -> limit ; $ last_page = intdiv ( intval ( $ this -> count ) , intval ( $ limit ) ) ; $ last_url = $ this -> offset_key . ( $ last_page * $ limit ) . $ this -> limit_key . $ limit ; return $ last_url ; } | Generate the last page url parameters as string . |
9,590 | public function getFirstPageParams ( ) { $ limit = $ this -> limit <= 0 ? $ this -> count : $ this -> limit ; $ first_url = $ this -> offset_key . '0' . $ this -> limit_key . $ limit ; return $ first_url ; } | Generate the first page url parameters as string . |
9,591 | public function getPaginationMetaData ( ) { $ pagination = [ 'count' => $ this -> count , 'offset' => $ this -> offset , 'limit' => $ this -> limit , 'next_page_params' => $ this -> getNextPageParams ( ) , ] ; return $ pagination ; } | Get a json encoded array with pagination metadata |
9,592 | public function recursiveReplace ( $ search , $ replace ) { $ json = json_encode ( $ this -> params ) ; $ json = str_replace ( $ search , $ replace , $ json ) ; $ this -> params = json_decode ( $ json , TRUE ) ; } | Search and replace function for multi level arrays |
9,593 | public function rollback ( ) { if ( $ this -> hasBackup ) { $ this -> params = $ this -> backup ; } else { throw new Exceptions \ NoValidBackup ( $ this -> params ) ; } } | Uses the backup array to revert the params array |
9,594 | public function activateSubscription ( $ hashString ) { $ subscription = ezcomSubscription :: fetchByHashString ( $ hashString ) ; if ( is_null ( $ subscription ) ) { $ this -> tpl -> setVariable ( 'error_message' , ezpI18n :: tr ( 'ezcomments/comment/activate' , 'There is no subscription with the hash string!' ) ) ; }... | Activate subscription If there is error set error_message to the template If activation succeeds set subscriber to the template |
9,595 | public function addSubscription ( $ email , $ user , $ contentID , $ languageID , $ subscriptionType , $ currentTime , $ activate = true ) { $ ezcommentsINI = eZINI :: instance ( 'ezcomments.ini' ) ; $ subscriber = ezcomSubscriber :: fetchByEmail ( $ email ) ; if ( is_null ( $ subscriber ) ) { $ subscriber = ezcomSubsc... | Add an subscription . If the subscriber is disabled throw an exception If there is no subscriber add one . If there is no subscription for the content add one |
9,596 | public static function sendActivationEmail ( $ contentObject , $ subscriber , $ subscription ) { $ transport = eZNotificationTransport :: instance ( 'ezmail' ) ; $ email = $ subscriber -> attribute ( 'email' ) ; $ tpl = eZTemplate :: factory ( ) ; $ tpl -> setVariable ( 'contentobject' , $ contentObject ) ; $ tpl -> se... | send activation email to the user |
9,597 | public static function cleanupExpiredSubscription ( $ time ) { $ startTime = time ( ) - $ time ; $ db = eZDB :: instance ( ) ; $ selectSql = "SELECT id FROM ezcomment_subscription WHERE subscription_time < $startTime AND enabled = 0" ; $ result = $ db -> arrayQuery ( $ selectSql ) ; if ( is_array ( $ result ) && count ... | clean up the subscription if the subscription has not been activate for very long |
9,598 | public function deleteSubscription ( $ email , $ contentObjectID , $ languageID ) { $ subscriber = ezcomSubscriber :: fetchByEmail ( $ email ) ; $ cond = array ( ) ; $ cond [ 'subscriber_id' ] = $ subscriber -> attribute ( 'id' ) ; $ cond [ 'content_id' ] = $ contentObjectID ; $ cond [ 'language_id' ] = $ languageID ; ... | delete the subscription given the subscriber s email |
9,599 | public static function instance ( $ tpl = null , $ module = null , $ params = null , $ className = null ) { $ object = null ; if ( is_null ( $ className ) ) { $ ini = eZINI :: instance ( 'ezcomments.ini' ) ; $ className = $ ini -> variable ( 'ManagerClasses' , 'SubscriptionManagerClass' ) ; } if ( ! is_null ( self :: $... | method for creating object |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.