idx int64 0 60.3k | question stringlengths 101 6.21k | target stringlengths 7 803 |
|---|---|---|
45,800 | public function find ( Uid $ uniqueId ) { if ( ! array_key_exists ( ( string ) $ uniqueId , $ this -> unitOfWorkStore ) ) { throw new UnitNotFoundException ( ) ; } return $ this -> unitOfWorkStore [ ( string ) $ uniqueId ] ; } | Finds the unit with the given Uid |
45,801 | public function add ( UnitOfWork $ unitOfWork ) { if ( $ this -> contains ( $ unitOfWork ) ) { throw new UnitIsAlreadyPresentException ( ) ; } $ this -> unitOfWorkStore [ $ unitOfWork -> getUniqueId ( ) ] = $ unitOfWork ; } | Adds a UnitOfWork to the repository |
45,802 | public function replace ( UnitOfWork $ unitOfWork ) { if ( ! $ this -> contains ( $ unitOfWork ) ) { throw new UnitNotPresentException ; } $ this -> unitOfWorkStore [ $ unitOfWork -> getUniqueId ( ) ] = $ unitOfWork ; } | Replaces with the given unit of work |
45,803 | protected function getReflectionMethod ( $ class , $ method ) { if ( ! isset ( $ this -> methodReflectors [ $ class ] ) ) { $ this -> methodReflectors [ $ class ] = [ ] ; } if ( ! isset ( $ this -> methodReflectors [ $ class ] [ $ method ] ) ) { $ this -> methodReflectors [ $ class ] [ $ method ] = new \ ReflectionMethod ( $ class , $ method ) ; } return $ this -> methodReflectors [ $ class ] [ $ method ] ; } | Returns a method reflection |
45,804 | protected function getReflectionProperty ( $ class , $ property ) { if ( ! isset ( $ this -> propertyReflectors [ $ class ] ) ) { $ this -> propertyReflectors [ $ class ] = [ ] ; } if ( ! isset ( $ this -> propertyReflectors [ $ class ] [ $ property ] ) ) { $ this -> propertyReflectors [ $ class ] [ $ property ] = new \ ReflectionProperty ( $ class , $ property ) ; } return $ this -> propertyReflectors [ $ class ] [ $ property ] ; } | Returns a property reflection |
45,805 | public function getProtectedMethod ( ... $ params ) { if ( is_string ( $ params [ 0 ] ) ) { list ( $ className , $ object , $ name ) = $ params ; } elseif ( is_object ( $ params [ 0 ] ) ) { list ( $ object , $ name ) = $ params ; $ className = get_class ( $ object ) ; } $ this -> checkOnObject ( $ object ) ; $ this -> checkOnMemberName ( $ name ) ; $ reflector = $ this -> getReflectionMethod ( $ className , $ name ) ; return $ reflector -> getClosure ( $ object ) ; } | Returns a method as closure |
45,806 | public function getProtectedProperty ( ... $ params ) { if ( is_string ( $ params [ 0 ] ) ) { list ( $ className , $ object , $ name ) = $ params ; } elseif ( is_object ( $ params [ 0 ] ) ) { list ( $ object , $ name ) = $ params ; $ className = get_class ( $ object ) ; } $ this -> checkOnObject ( $ object ) ; $ this -> checkOnMemberName ( $ name ) ; $ reflector = new \ ReflectionProperty ( $ className , $ name ) ; $ isProtected = $ reflector -> isProtected ( ) || $ reflector -> isPrivate ( ) ; if ( $ isProtected ) { $ reflector -> setAccessible ( true ) ; } $ value = $ reflector -> getValue ( $ object ) ; if ( $ isProtected ) { $ reflector -> setAccessible ( false ) ; } return $ value ; } | Returns a value of a protected property of the object |
45,807 | public function setProtectedProperty ( ... $ params ) { if ( is_string ( $ params [ 0 ] ) ) { list ( $ className , $ object , $ name , $ value ) = $ params ; } elseif ( is_object ( $ params [ 0 ] ) ) { list ( $ object , $ name , $ value ) = $ params ; $ className = get_class ( $ object ) ; } $ this -> checkOnObject ( $ object ) ; $ this -> checkOnMemberName ( $ name ) ; $ reflector = $ this -> getReflectionProperty ( $ className , $ name ) ; $ isProtected = $ reflector -> isProtected ( ) || $ reflector -> isPrivate ( ) ; if ( $ isProtected ) { $ reflector -> setAccessible ( true ) ; } $ reflector -> setValue ( $ object , $ value ) ; if ( $ isProtected ) { $ reflector -> setAccessible ( false ) ; } } | Sets a protected property for the object |
45,808 | protected function getTokenString ( ) { $ result = Request :: post ( '_token' , '' ) ; if ( '' == $ result ) { $ result = Request :: get ( '_token' , '' ) ; } if ( '' == $ result ) { $ result = isset ( $ _SERVER [ 'X-CSRF-TOKEN' ] ) ? $ _SERVER [ 'X-CSRF-TOKEN' ] : '' ; } return $ result ; } | get token string |
45,809 | public static function removeKeysFromMultiArray ( & $ array , $ keys ) { foreach ( $ array as $ key => & $ value ) { if ( is_array ( $ value ) ) { self :: traverseArray ( $ value , $ keys ) ; } else { if ( in_array ( $ key , $ keys ) || '' == $ value ) { unset ( $ array [ $ key ] ) ; } } } return $ array ; } | Traverse an array unsetting keys |
45,810 | public static function listToMultiArray ( $ array ) { $ nested = [ ] ; $ depths = [ ] ; foreach ( $ array as $ key => $ arr ) { if ( $ arr [ 'depth' ] == 0 ) { $ nested [ $ key ] = $ arr ; } else { $ parent = & $ nested ; for ( $ i = 1 ; $ i <= ( $ arr [ 'depth' ] ) ; $ i ++ ) { $ parent = & $ parent [ $ depths [ $ i ] ] ; } $ parent [ 'pages' ] [ $ key ] = $ arr ; } $ depths [ $ arr [ 'depth' ] + 1 ] = $ key ; } return $ nested ; } | transform a list into a multidimensional array using a depth value |
45,811 | public function upload ( $ filePath , $ contentType = 'text/plain' ) { $ s3FileName = $ this -> getFilePathAndUniquePrefix ( ) . basename ( $ filePath ) ; list ( $ bucket , $ prefix ) = explode ( '/' , $ this -> s3path , 2 ) ; $ this -> s3client -> putObject ( [ 'Bucket' => $ bucket , 'Key' => ( empty ( $ prefix ) ? '' : ( trim ( $ prefix , '/' ) . '/' ) ) . $ s3FileName , 'ContentType' => $ contentType , 'ACL' => 'private' , 'ServerSideEncryption' => 'AES256' , 'SourceFile' => $ filePath , ] ) ; return $ this -> withUrlPrefix ( $ s3FileName ) ; } | Uploads file to s3 |
45,812 | public function uploadString ( $ name , $ content , $ contentType = 'text/plain' ) { $ s3FileName = $ this -> getFilePathAndUniquePrefix ( ) . $ name ; list ( $ bucket , $ prefix ) = explode ( '/' , $ this -> s3path , 2 ) ; $ this -> s3client -> putObject ( [ 'Bucket' => $ bucket , 'Key' => ( empty ( $ prefix ) ? '' : ( trim ( $ prefix , '/' ) . '/' ) ) . $ s3FileName , 'ContentType' => $ contentType , 'ACL' => 'private' , 'ServerSideEncryption' => 'AES256' , 'Body' => $ content , ] ) ; return $ this -> withUrlPrefix ( $ s3FileName ) ; } | Uploads string as file to s3 |
45,813 | public static function create ( ProviderRepository $ providerRepository = null ) { $ container = new Container ( $ providerRepository ) ; if ( ! $ container -> isProvided ( AnnotationServiceProvider :: class ) ) { $ container -> addProvider ( AnnotationServiceProvider :: class ) ; } $ container -> add ( Container :: class , function ( ) use ( $ container ) { return $ container ; } ) -> alias ( ContainerInterface :: class ) ; return $ container ; } | create a new container instance |
45,814 | private function connecting ( ) : void { $ this -> connected = false ; $ this -> closing ? $ this -> closed ( ) -> resolve ( ) : $ this -> client = Socket :: connect ( $ this -> endpoint , $ this -> events ) ; } | reconnect to server if conn closed or error |
45,815 | protected function getRoutes ( ) : array { uasort ( $ this -> routes , function ( RouteInterface $ left , RouteInterface $ right ) { if ( $ left instanceof GroupRoute || $ right instanceof GroupRoute ) { return 1 ; } return 0 ; } ) ; return $ this -> routes ; } | Get routes . |
45,816 | public static function encountered ( Throwable $ exception , object $ target ) : CannotHydrate { return new HydrationFailed ( withMessage ( 'Could not hydrate the `%s`: %s' , theClassOfThe ( $ target ) , $ exception -> getMessage ( ) ) , 0 , $ exception ) ; } | Notifies the client code that an exception was encountered during the hydration process . |
45,817 | public function getWebResourceClassName ( $ contentType ) { return ( $ this -> hasMappedWebResourceClassName ( $ contentType ) ) ? $ this -> contentTypeWebResourceMap [ ( string ) $ contentType ] : self :: DEFAULT_WEB_RESOURCE_MODEL ; } | Get the WebResource subclass name for a given content type |
45,818 | public function setConfig ( $ config ) { $ configObject = $ this -> getConfig ( ) ; if ( is_object ( $ config ) ) { $ config = get_object_vars ( $ config ) ; } foreach ( ( array ) $ config as $ key => $ value ) { $ configObject -> $ key = $ value ; } return $ this ; } | Sets new configuration for the loader |
45,819 | public function registerAssetBundle ( $ name ) { if ( ( $ bundle = $ this -> getAssetBundleFromView ( $ name ) ) === false ) { return $ bundle ; } $ config = $ this -> getConfig ( ) ; if ( ! ( $ module = $ config -> getModule ( $ name ) ) ) { $ module = $ config -> addModule ( $ name ) ; } $ options = $ bundle -> jsOptions ; if ( ! isset ( $ options [ 'position' ] ) ) { $ options [ 'position' ] = View :: POS_END ; } $ options [ 'baseUrl' ] = $ bundle -> baseUrl ; $ module -> setOptions ( $ options ) ; foreach ( $ bundle -> depends as $ dependency ) { if ( ( $ dependency = $ this -> registerAssetBundle ( $ dependency ) ) !== false ) { $ module -> addDependency ( $ dependency ) ; } } $ this -> importJsFilesFromBundle ( $ bundle , $ module ) ; return $ module ; } | Registers asset bundle in the loader |
45,820 | public function processAssets ( ) { $ jsExpressions = [ ] ; foreach ( [ View :: POS_HEAD , View :: POS_BEGIN , View :: POS_END , View :: POS_LOAD , View :: POS_READY ] as $ position ) { if ( $ this -> ignoredPositions -> match ( $ position ) ) { continue ; } if ( ( $ jsExpression = $ this -> createJsExpression ( $ position ) ) === null ) { continue ; } $ jsExpressions [ $ position ] = $ jsExpression ; } $ this -> doRender ( $ jsExpressions ) ; } | Performs processing of assets registered in the view |
45,821 | public function set ( $ key , $ data , $ ttl = null ) { if ( $ ttl ) { $ now = new \ DateTime ( 'now' , new \ DateTimeZone ( 'UTC' ) ) ; $ expire = ( int ) $ now -> format ( 'U' ) + $ ttl ; } else { $ expire = 0 ; } $ entry = array ( 'expire' => $ expire , 'value' => $ data ) ; $ this -> storage [ $ key ] = $ entry ; return true ; } | Set data to cache storage |
45,822 | public static function json ( $ var , $ continue = false , $ hide = false , $ return = false ) { $ Stop = new \ Stop \ Dumper \ Json ( $ hide , $ continue , $ return , Dumper \ AbstractDumper :: FORMAT_JSON ) ; $ Stop -> var_dump ( $ var ) ; } | dump a variable as json |
45,823 | protected function buildSql ( array $ settings ) { $ result = $ this -> getType ( ) ; $ settings [ 'join' ] = $ settings [ 'seperator' ] . $ settings [ 'indent' ] ; $ result .= $ this -> buildBeforeAfter ( 'AFTER' , 'TYPE' , $ settings ) ; foreach ( $ this -> getConfigs ( ) as $ pos => $ prefix ) { $ result .= $ this -> buildBeforeAfter ( 'BEFORE' , $ pos , $ settings ) ; $ method = 'build' . ucfirst ( strtolower ( $ pos ) ) ; $ result .= $ this -> { $ method } ( $ prefix , $ settings ) ; $ result .= $ this -> buildBeforeAfter ( 'AFTER' , $ pos , $ settings ) ; } $ result .= $ this -> buildBeforeAfter ( 'AFTER' , 'STMT' , $ settings ) ; return $ result ; } | Build SQL statement clauses |
45,824 | protected function getFormEntity ( Request $ request ) { if ( $ this -> formEntity === null ) { $ entityId = $ request -> get ( 'id' ) ; $ repository = $ this -> getRepository ( ) ; $ entity = null ; $ id = 0 ; if ( ! empty ( $ entityId ) && $ entityId !== null ) { $ entity = $ repository -> findOneById ( $ entityId ) ; $ id = $ entity -> getId ( ) ; } if ( ! is_object ( $ entity ) || empty ( $ id ) ) { $ entity_class_name = $ repository -> getClassName ( ) ; $ entity = new $ entity_class_name ( ) ; } $ this -> formEntity = $ entity ; } return $ this -> formEntity ; } | Entity object for the form Dont load the object twice and load from this method |
45,825 | protected function getFilesystem ( ) { if ( ! isset ( $ this -> filesystem ) ) { $ this -> filesystem = new Filesystem ( $ this -> getAdapter ( ) ) ; } return $ this -> filesystem ; } | Retrives the Filesystem object . Instantiate if it hasn t already been . |
45,826 | public function create ( $ template ) { if ( ! isset ( $ this -> plotters [ $ template ] ) ) { throw new \ InvalidArgumentException ( "Unknown template [$template]" ) ; } $ className = $ this -> plotters [ $ template ] ; return new $ className ( $ this -> finderFactory ) ; } | Just get a new plotter by template! |
45,827 | public static function groupByType ( array $ objects ) { $ perType = [ ] ; foreach ( $ objects as $ object ) { $ type = $ object -> getType ( ) ; if ( ! isset ( $ perType [ $ type ] ) ) { $ perType [ $ type ] = [ ] ; } $ perType [ $ type ] [ ] = $ object ; } return $ perType ; } | Group typed objects by their type |
45,828 | public function request ( $ verb , $ path , $ accept , array $ customCURLOptions = [ ] ) { $ verb = strtoupper ( trim ( $ verb ) ) ; $ instantiateClass = "\\Lamoni\\RESTLyte\\RESTLyteRequest\\RESTLyteRequest{$this->getResponseType()}" ; $ request = new $ instantiateClass ( $ this -> getServer ( ) , $ verb , $ path , $ this -> getAuthCredentials ( ) , $ accept , $ this -> getVerifySSLPeer ( ) , $ this -> getHTTPHeaders ( ) , $ customCURLOptions ) ; return $ request -> getResponse ( ) ; } | Base for REST requests |
45,829 | public function post ( $ path , $ postData , $ accept = "" ) { return $ this -> request ( 'POST' , $ path , $ accept , [ CURLOPT_POSTFIELDS => $ postData ] ) ; } | Launches a POST request to the server |
45,830 | public function put ( $ path , $ postData , $ accept = "" ) { return $ this -> request ( 'PUT' , $ path , $ accept , [ CURLOPT_POSTFIELDS => $ postData ] ) ; } | Launches a PUT request to the server |
45,831 | public function patch ( $ path , $ postData , $ accept = "" ) { return $ this -> request ( 'PATCH' , $ path , $ accept , [ CURLOPT_POSTFIELDS => $ postData ] ) ; } | Launches a PATCH request to the server |
45,832 | public function delete ( $ path , $ postData , $ accept = "" ) { return $ this -> request ( 'DELETE' , $ path , $ accept , [ CURLOPT_POSTFIELDS => $ postData ] ) ; } | Launches a DELETE request to the server |
45,833 | public function isWellFormed ( ) { if ( ! is_array ( $ this -> decodedRawOutput ) ) { return false ; } if ( ! isset ( $ this -> decodedRawOutput [ 0 ] ) || ! is_string ( $ this -> decodedRawOutput [ 0 ] ) ) { return false ; } if ( ! isset ( $ this -> decodedRawOutput [ 1 ] ) || ! is_array ( $ this -> decodedRawOutput [ 1 ] ) ) { return false ; } return true ; } | Is the decoded output of the format we expect? Should be a two - element array with item zero being the path of the file that was linted and the item one being the result set |
45,834 | public function setStatus ( Result \ ResultStatus $ status ) { if ( Result \ ResultStatus :: UNPROCESSED !== $ status -> getValue ( ) ) { $ this -> transacted = true ; $ this -> dateTransacted = new DateTime ( ) ; } if ( ! $ this -> transaction -> isParent ( ) && Result \ ResultStatus :: ERROR !== $ status -> getValue ( ) && Result \ ResultStatus :: UNPROCESSED !== $ status -> getValue ( ) ) { $ this -> transaction -> getParent ( ) -> setStatus ( $ status ) ; } $ this -> transaction -> setStatus ( $ status ) ; $ this -> status = $ status ; } | Sets the result type |
45,835 | public static function doInsert ( $ criteria , ConnectionInterface $ con = null ) { if ( null === $ con ) { $ con = Propel :: getServiceContainer ( ) -> getWriteConnection ( GroupTableMap :: DATABASE_NAME ) ; } if ( $ criteria instanceof Criteria ) { $ criteria = clone $ criteria ; } else { $ criteria = $ criteria -> buildCriteria ( ) ; } if ( $ criteria -> containsKey ( GroupTableMap :: COL_ID ) && $ criteria -> keyContainsValue ( GroupTableMap :: COL_ID ) ) { throw new PropelException ( 'Cannot insert a value for auto-increment primary key (' . GroupTableMap :: COL_ID . ')' ) ; } $ query = GroupQuery :: create ( ) -> mergeWith ( $ criteria ) ; return $ con -> transaction ( function ( ) use ( $ con , $ query ) { return $ query -> doInsert ( $ con ) ; } ) ; } | Performs an INSERT on the database given a Group or Criteria object . |
45,836 | public function queueEmail ( $ type , $ to , $ fromEmail , $ fromName , $ subject , $ body = null , $ contentType = 'text/html' , $ template = null , $ parameters = [ ] , $ cc = [ ] , $ bcc = [ ] , $ delaySeconds = 0 ) { $ payload = [ 'to' => $ to , 'fromName' => $ fromName , 'fromEmail' => $ fromEmail , 'subject' => $ subject , 'cc' => $ cc , 'bcc' => $ bcc , ] ; if ( $ type === self :: SEND_TEMPLATE ) { $ method = 'performSendTemplate' ; $ payload [ 'template' ] = $ template ; $ payload [ 'parameters' ] = $ parameters ; } else { $ method = 'performSend' ; $ payload [ 'body' ] = $ body ; $ payload [ 'contentType' ] = $ contentType ; } return $ this -> addJob ( 'email' , $ payload , self :: class , $ delaySeconds , $ method ) ; } | Queues an email to be sent |
45,837 | public function restoreCommand ( $ selectedBackup = null ) { $ this -> initialize ( ) ; if ( is_null ( $ selectedBackup ) ) { $ availableVersions = $ this -> backupService -> getAvailableVersions ( ) ; if ( count ( $ availableVersions ) <= 0 ) { $ this -> output -> outputLine ( ) ; $ this -> output -> outputLine ( '<b>You have no Backups!</b>' ) ; $ this -> output -> outputLine ( ) ; $ this -> output -> outputLine ( 'Call \'./flow backup:now\' and create one.' ) ; $ this -> output -> outputLine ( ) ; return ; } $ selectedBackup = $ this -> askWithSelectForVersion ( $ availableVersions ) ; } $ this -> backupService -> restoreBackup ( $ selectedBackup ) ; } | Select & restore a Backup |
45,838 | public function listCommand ( ) { $ this -> output -> outputLine ( ) ; $ this -> output -> outputLine ( '<b>Available Backups</b>' ) ; $ this -> output -> outputLine ( ) ; $ this -> output -> outputLine ( '<b>Identifier Date Time</b>' ) ; $ this -> initialize ( ) ; $ availableVersions = $ this -> backupService -> getAvailableVersions ( ) ; foreach ( $ availableVersions as $ version ) { if ( is_numeric ( $ version ) ) { $ this -> output -> outputLine ( $ version . ': ' . date ( 'd.m.Y H:i' , $ version * 1 ) ) ; } } $ this -> output -> outputLine ( ) ; } | Show available Backups |
45,839 | public function clearCommand ( $ force = null ) { $ this -> initialize ( ) ; $ this -> backupService -> removeAllBackups ( ) ; if ( $ force === true ) { $ this -> backupService -> removeKeyfile ( ) ; } } | Remove all Backups |
45,840 | public function attach ( $ methods , $ match , $ callable ) { if ( is_string ( $ methods ) ) { $ methods = [ $ methods ] ; } $ route = new Route ( $ methods , $ callable ) ; $ this -> storage [ $ match ] = $ route ; return $ route ; } | Attach a route field to storage . |
45,841 | public static function registerCoreClass ( string $ class ) : bool { if ( class_exists ( $ class ) === false ) { return false ; } $ check = new ReflectionClass ( $ class ) ; if ( $ check -> implementsInterface ( "TheCMSThread\\Classes\\Core" ) === true ) { self :: $ core_class = $ class ; return true ; } else { return false ; } } | Register a core framework class |
45,842 | public static function registerModulesClass ( string $ class ) : bool { if ( class_exists ( $ class ) === false ) { return false ; } $ check = new ReflectionClass ( $ class ) ; if ( $ check -> implementsInterface ( "TheCMSThread\\Classes\\Modules" ) === true ) { self :: $ modules_class = $ class ; return true ; } else { return false ; } } | Register a modules framework class |
45,843 | public static function registerThemeClass ( string $ class ) : bool { if ( class_exists ( $ class ) === false ) { return false ; } $ check = new ReflectionClass ( $ class ) ; if ( $ check -> implementsInterface ( "TheCMSThread\\Classes\\Theme" ) === true ) { self :: $ theme_class = $ class ; return true ; } else { return false ; } } | Register a theme class |
45,844 | public static function registerPluginClass ( string $ name , string $ class ) : bool { if ( class_exists ( $ class ) === false ) { return false ; } if ( self :: $ plugin_classes === null ) { self :: $ plugin_classes = [ ] ; } $ check = new ReflectionClass ( $ class ) ; if ( $ check -> implementsInterface ( "TheCMSThread\\Classes\\Plugin" ) === true ) { self :: $ plugin_classes [ $ name ] = $ class ; return true ; } else { return false ; } } | Register a plugin class |
45,845 | public static function getPluginClass ( string $ name ) : string { $ class = "" ; if ( empty ( $ name ) === false && empty ( self :: $ plugin_classes [ $ name ] ) === false ) { $ class = self :: $ plugin_classes [ $ name ] ; } return $ class ; } | Return a plugin class name registered under a given name |
45,846 | public static function registerExtensionClass ( string $ name , string $ class ) : bool { if ( class_exists ( $ class ) === false ) { return false ; } if ( self :: $ extension_classes === null ) { self :: $ extension_classes = [ ] ; } $ check = new ReflectionClass ( $ class ) ; if ( $ check -> implementsInterface ( "TheCMSThread\\Classes\\Extension" ) === true ) { self :: $ extension_classes [ $ name ] = $ class ; return true ; } else { return false ; } } | Register an extension framework class |
45,847 | public static function getExtensionClass ( string $ name ) : string { $ class = "" ; if ( empty ( $ name ) === false && empty ( self :: $ extension_classes [ $ name ] ) === false ) { $ class = self :: $ extension_classes [ $ name ] ; } return $ class ; } | Return a extension framework class name registered under a given name |
45,848 | public static function registerAdminClass ( string $ name , string $ class ) : bool { if ( class_exists ( $ class ) === false ) { return false ; } if ( self :: $ admin_classes === null ) { self :: $ admin_classes = [ ] ; } $ check = new ReflectionClass ( $ class ) ; if ( $ check -> implementsInterface ( "TheCMSThread\\Classes\\Admin" ) === true ) { self :: $ admin_classes [ $ name ] = $ class ; return true ; } else { return false ; } } | Register an admin class |
45,849 | public static function getAdminClass ( string $ name ) : string { $ class = "" ; if ( empty ( $ name ) === false && empty ( self :: $ admin_classes [ $ name ] ) === false ) { $ class = self :: $ admin_classes [ $ name ] ; } return $ class ; } | Return a admin class name registered under a given name |
45,850 | public static function register ( ) { $ namespace = "Vinala\App\Events" ; foreach ( get_declared_classes ( ) as $ value ) { if ( Strings :: contains ( $ value , $ namespace ) ) { $ name = self :: getName ( $ value ) ; $ events = $ value :: getEvents ( ) ; if ( ! is_null ( $ events ) ) { foreach ( $ events as $ key => $ value ) { $ data [ $ name . '.' . $ key ] = $ value ; } } self :: $ listners = array_collapse ( [ $ data , self :: $ listners ] ) ; } } } | Register all listners . |
45,851 | public static function trigger ( ) { $ args = func_get_args ( ) ; $ haveParams = count ( $ args ) > 1 ? true : false ; $ events = self :: splite ( $ args [ 0 ] ) ; if ( $ haveParams && count ( $ events ) > 1 ) { throw new ManyListenersArgumentsException ( ) ; } if ( count ( $ events ) > 1 ) { self :: runMany ( $ events ) ; } elseif ( count ( $ events ) == 1 ) { self :: runOne ( $ events , array_except ( $ args , 0 ) ) ; } return true ; } | Fire a trigger . |
45,852 | protected static function splite ( $ pattern ) { if ( is_array ( $ pattern ) ) { $ events = [ ] ; foreach ( $ pattern as $ value ) { $ events = array_collapse ( [ $ events , self :: extract ( $ value ) ] ) ; } return $ events ; } elseif ( is_string ( $ pattern ) ) { return self :: extract ( $ pattern ) ; } } | Get events from event pattern . |
45,853 | protected static function extract ( $ pattern ) { if ( str_contains ( $ pattern , '|' ) ) { $ segements = explode ( '|' , $ pattern ) ; $ events [ $ segements [ 0 ] ] = explode ( '.' , $ segements [ 1 ] ) ; } else { $ segements = explode ( '.' , $ pattern ) ; $ events [ $ segements [ 0 ] ] = $ segements [ 1 ] ; } return $ events ; } | Extract events from string pattern . |
45,854 | public static function runMany ( $ events ) { foreach ( $ events as $ key => $ value ) { $ name = '\Vinala\App\Events\\' . $ key ; $ object = new $ name ( ) ; if ( is_array ( $ value ) ) { foreach ( $ value as $ function ) { $ function = self :: $ listners [ $ key . '.' . $ function ] ; $ object -> $ function ( ) ; } } elseif ( is_string ( $ value ) ) { $ function = self :: $ listners [ $ key . '.' . $ value ] ; $ object -> $ function ( ) ; } } return true ; } | Run and execute many events trigger . |
45,855 | public static function runOne ( $ events , $ args ) { foreach ( $ events as $ key => $ value ) { $ name = '\Vinala\App\Events\\' . $ key ; $ object = new $ name ( ) ; $ function = self :: $ listners [ $ key . '.' . $ value ] ; call_user_func_array ( [ $ object , $ function ] , $ args ) ; } return true ; } | Run and execute one event trigger . |
45,856 | public function rawLog ( string $ type = '' , string $ message = '' , ? string $ source = null , ? string $ excp = null ) : bool { $ src = $ source !== null ? \ sprintf ( '[%s] ' , \ is_object ( $ source ) ? '\\' . \ get_class ( $ source ) : ( string ) $ source ) : '' ; $ exc = $ excp !== null && ( $ excp instanceof \ Exception ) ? \ sprintf ( '[Ex: %s] ' , $ excp -> getMessage ( ) ) : '' ; $ exc = \ str_replace ( [ "\r" , "\n" , "\t" ] , '' , $ exc ) ; $ msg = \ sprintf ( '%s %s %s%s%s%s' , \ date ( 'd-m-Y H:i:s' ) , $ type , $ src , $ exc , $ message , Tags :: CRLF ) ; return File :: append ( $ this -> logFile , $ msg ) ; } | Logs message to file |
45,857 | public function logDebug ( string $ message = '' , ? string $ source = null , ? string $ exception = null ) : bool { $ ret = false ; if ( $ this -> logLevel & Log :: LOG_DEBUG ) { $ ret = $ this -> rawLog ( '[ DEBUG]' , $ message , $ source , $ exception ) ; } return $ ret ; } | Logs debug information |
45,858 | public function methods ( ) { return $ this -> cache ( __METHOD__ , function ( ) { return array_unique ( array_merge ( $ this -> publicMethods ( ) , $ this -> protectedMethods ( ) , $ this -> privateMethods ( ) , $ this -> staticMethods ( ) ) ) ; } ) ; } | Return an array of public protected private and static methods . |
45,859 | public function properties ( ) { return $ this -> cache ( __METHOD__ , function ( ) { return array_unique ( array_merge ( $ this -> publicProperties ( ) , $ this -> protectedProperties ( ) , $ this -> privateProperties ( ) , $ this -> staticProperties ( ) ) ) ; } ) ; } | Return an array of public protected private and static properties . |
45,860 | public function traits ( ) { $ traits = $ this -> reflection ( ) -> getTraitNames ( ) ; $ parent = get_parent_class ( $ this -> _class ) ; while ( $ parent ) { $ traits = array_merge ( $ traits , class_uses ( $ parent ) ) ; $ parent = get_parent_class ( $ parent ) ; } return array_values ( $ traits ) ; } | Return an array of traits that the class implements . |
45,861 | protected function _methods ( $ key , $ scope ) { return $ this -> cache ( $ key , function ( ) use ( $ scope ) { $ methods = [ ] ; foreach ( $ this -> reflection ( ) -> getMethods ( $ scope ) as $ method ) { $ methods [ ] = $ method -> getName ( ) ; } return $ methods ; } ) ; } | Return an array of methods for the defined scope . |
45,862 | protected function _properties ( $ key , $ scope ) { return $ this -> cache ( $ key , function ( ) use ( $ scope ) { $ props = [ ] ; foreach ( $ this -> reflection ( ) -> getProperties ( $ scope ) as $ prop ) { $ props [ ] = $ prop -> getName ( ) ; } return $ props ; } ) ; } | Return an array of properties for the defined scope . |
45,863 | protected function check_access ( $ action = null ) { is_null ( $ action ) and $ action = $ this -> request -> action ; if ( $ this -> has_access ( $ action ) === false ) { $ context = array ( 'form' => array ( '%action%' => $ action , '%items%' => $ this -> get_name ( 999 ) , ) ) ; \ Logger :: instance ( 'alert' ) -> error ( gettext ( 'You are not authorized to %action% %items%.' ) , $ context ) ; return \ Response :: redirect_back ( \ Uri :: admin ( false ) ) ; } } | Checks whether user has access to an action |
45,864 | protected function find ( $ id = null ) { $ query = $ this -> query ( ) ; $ query -> where ( 'id' , $ id ) ; if ( is_null ( $ id ) or is_null ( $ model = $ query -> get_one ( ) ) ) { throw new \ HttpNotFoundException ( ) ; } return $ model ; } | Finds an entity of model |
45,865 | protected function forge ( $ data = [ ] , $ new = true , $ view = null , $ cache = true ) { return call_user_func ( [ $ this -> get_model ( ) , 'forge' ] , $ data , $ new , $ view , $ cache ) ; } | Forge a new Model |
45,866 | public static function create ( $ name , $ message , $ view ) { $ root = Process :: root ; $ name = ucfirst ( $ name ) ; $ path = $ root . "app/exceptions/$name.php" ; if ( ! File :: exists ( $ path ) ) { File :: put ( $ path , self :: set ( $ name , $ message , $ view ) ) ; return true ; } else { return false ; } } | Create exception . |
45,867 | protected function includeDefaultIncludes ( $ model , $ data ) { $ returnData = [ ] ; if ( ! empty ( $ this -> defaultIncludes ) ) { foreach ( $ this -> defaultIncludes as $ include ) { $ returnData [ $ include ] = $ this -> includeByName ( $ include , $ model ) ; } } return array_merge ( $ data , $ returnData ) ; } | Include default includes |
45,868 | protected function includeAvailableIncludes ( $ model , $ data ) { $ includes = $ this -> getAvailableIncludesFromUrlParameters ( ) ; $ returnData = [ ] ; if ( ! empty ( $ includes ) && ! empty ( $ this -> availableIncludes ) ) { foreach ( $ this -> availableIncludes as $ include ) { if ( in_array ( $ include , $ includes ) ) { $ returnData [ $ include ] = $ this -> includeByName ( $ include , $ model ) ; } } } return array_merge ( $ data , $ returnData ) ; } | Include available includes |
45,869 | protected function includeByName ( $ name , $ model ) { $ functionName = sprintf ( 'include%s' , ucfirst ( $ name ) ) ; if ( ! method_exists ( static :: class , $ functionName ) ) { throw new \ Exception ( sprintf ( 'The function name "%s" does not exists on %s' , $ functionName , static :: class ) ) ; } return $ this -> { $ functionName } ( $ model ) ; } | Call the include function thats equal to the name |
45,870 | public function findByHashes ( array $ hashes ) : array { $ result = [ ] ; if ( count ( $ hashes ) > 0 ) { $ queryBuilder = $ this -> entityManager -> createQueryBuilder ( ) ; $ queryBuilder -> select ( 'if' ) -> from ( IconFile :: class , 'if' ) -> andWhere ( 'if.hash IN (:hashes)' ) -> setParameter ( 'hashes' , array_values ( array_map ( 'hex2bin' , $ hashes ) ) ) ; $ result = $ queryBuilder -> getQuery ( ) -> getResult ( ) ; } return $ result ; } | Finds the icon files with the specified hashes . |
45,871 | public function removeOrphans ( ) : void { $ hashes = $ this -> findOrphanedHashes ( ) ; if ( count ( $ hashes ) > 0 ) { $ this -> removeHashes ( $ hashes ) ; } } | Removes any orphaned icon files i . e . icon files no longer used by any icon . |
45,872 | protected function findOrphanedHashes ( ) : array { $ queryBuilder = $ this -> entityManager -> createQueryBuilder ( ) ; $ queryBuilder -> select ( 'if.hash AS hash' ) -> from ( IconFile :: class , 'if' ) -> leftJoin ( 'if.icons' , 'i' ) -> andWhere ( 'i.id IS NULL' ) ; $ result = [ ] ; foreach ( $ queryBuilder -> getQuery ( ) -> getResult ( ) as $ data ) { $ result [ ] = $ data [ 'hash' ] ; } return $ result ; } | Returns the hashes of orphaned icon files which are no longer used by any icon . |
45,873 | protected function removeHashes ( array $ hashes ) : void { $ queryBuilder = $ this -> entityManager -> createQueryBuilder ( ) ; $ queryBuilder -> delete ( IconFile :: class , 'if' ) -> andWhere ( 'if.hash IN (:hashes)' ) -> setParameter ( 'hashes' , array_values ( $ hashes ) ) ; $ queryBuilder -> getQuery ( ) -> execute ( ) ; } | Removes the icon files with the specified hashes from the database . |
45,874 | public function exec ( $ arguments ) { $ options = $ this -> parse ( ) ; if ( is_integer ( $ options ) ) { return $ options ; } $ instance = $ options [ "__instance" ] ; $ method = $ options [ "__method" ] ; unset ( $ options [ "__instance" ] ) ; unset ( $ options [ "__method" ] ) ; try { return ( int ) Misc :: reflectionFunction ( [ $ instance , $ method ] , self :: adjustOptions ( $ options ) ) ; } catch ( Exception $ e ) { return $ this -> printError ( $ e -> getMessage ( ) ) ; } } | Forwards the call to parsed module name and action |
45,875 | private static function adjustOptions ( array $ options ) { $ result = [ ] ; foreach ( $ options as $ key => $ value ) { $ result [ str_replace ( "-" , "_" , $ key ) ] = $ value ; } return $ result ; } | replaces dashes with underscore in keys of an array |
45,876 | private function ident ( $ text , $ length = 4 , $ chunk = 76 , $ break = "\n" ) { $ lines = [ ] ; foreach ( explode ( $ break , $ text ) as $ line ) { $ text = trim ( wordwrap ( $ line , $ chunk - $ length , $ break ) ) ; foreach ( explode ( $ break , $ text ) as $ part ) { $ lines [ ] = str_repeat ( " " , $ length ) . $ part ; } } return implode ( $ break , $ lines ) ; } | Idents and chunk splits a text |
45,877 | public function translatePlural ( $ singular , $ plural , $ number ) { $ this -> checkTranslator ( ) ; return $ this -> translator -> translatePlural ( $ singular , $ plural , $ number ) ; } | Translates the provided message to singular or plural according to the number |
45,878 | public function showAction ( MeasureUnit $ measureunit ) { $ editForm = $ this -> createForm ( MeasureUnitType :: class , $ measureunit , array ( 'action' => $ this -> generateUrl ( 'admin_shop_measure_unit_update' , array ( 'id' => $ measureunit -> getid ( ) ) ) , 'method' => 'PUT' , ) ) ; $ deleteForm = $ this -> createDeleteForm ( $ measureunit -> getId ( ) , 'admin_shop_measure_unit_delete' ) ; return array ( 'measureunit' => $ measureunit , 'edit_form' => $ editForm -> createView ( ) , 'delete_form' => $ deleteForm -> createView ( ) , ) ; } | Finds and displays a MeasureUnit entity . |
45,879 | public function newAction ( ) { $ measureunit = new MeasureUnit ( ) ; $ form = $ this -> createForm ( MeasureUnitType :: class , $ measureunit ) ; return array ( 'measureunit' => $ measureunit , 'form' => $ form -> createView ( ) , ) ; } | Displays a form to create a new MeasureUnit entity . |
45,880 | public function createAction ( Request $ request ) { $ measureunit = new MeasureUnit ( ) ; $ form = $ this -> createForm ( new MeasureUnitType ( ) , $ measureunit ) ; if ( $ form -> handleRequest ( $ request ) -> isValid ( ) ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ em -> persist ( $ measureunit ) ; $ em -> flush ( ) ; return $ this -> redirect ( $ this -> generateUrl ( 'admin_shop_measure_unit_show' , array ( 'id' => $ measureunit -> getId ( ) ) ) ) ; } return array ( 'measureunit' => $ measureunit , 'form' => $ form -> createView ( ) , ) ; } | Creates a new MeasureUnit entity . |
45,881 | public function updateAction ( MeasureUnit $ measureunit , Request $ request ) { $ editForm = $ this -> createForm ( new MeasureUnitType ( ) , $ measureunit , array ( 'action' => $ this -> generateUrl ( 'admin_shop_measure_unit_update' , array ( 'id' => $ measureunit -> getid ( ) ) ) , 'method' => 'PUT' , ) ) ; if ( $ editForm -> handleRequest ( $ request ) -> isValid ( ) ) { $ this -> getDoctrine ( ) -> getManager ( ) -> flush ( ) ; return $ this -> redirect ( $ this -> generateUrl ( 'admin_shop_measure_unit_show' , array ( 'id' => $ measureunit -> getId ( ) ) ) ) ; } $ deleteForm = $ this -> createDeleteForm ( $ measureunit -> getId ( ) , 'admin_shop_measure_unit_delete' ) ; return array ( 'measureunit' => $ measureunit , 'edit_form' => $ editForm -> createView ( ) , 'delete_form' => $ deleteForm -> createView ( ) , ) ; } | Edits an existing MeasureUnit entity . |
45,882 | public function sortAction ( $ field , $ type ) { $ this -> setOrder ( 'measureunit' , $ field , $ type ) ; return $ this -> redirect ( $ this -> generateUrl ( 'admin_shop_measure_unit' ) ) ; } | Save order . |
45,883 | public function deleteAction ( MeasureUnit $ measureunit , Request $ request ) { $ form = $ this -> createDeleteForm ( $ measureunit -> getId ( ) , 'admin_shop_measure_unit_delete' ) ; if ( $ form -> handleRequest ( $ request ) -> isValid ( ) ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ em -> remove ( $ measureunit ) ; $ em -> flush ( ) ; } return $ this -> redirect ( $ this -> generateUrl ( 'admin_shop_measure_unit' ) ) ; } | Deletes a MeasureUnit entity . |
45,884 | protected function getScript ( ) { if ( null === $ this -> getScriptName ( ) ) { $ request = $ this -> frontController -> getRequest ( ) ; $ this -> setScriptName ( $ request -> getControllerName ( ) . DIRECTORY_SEPARATOR . $ request -> getActionName ( ) ) ; } return $ this -> getScriptName ( ) . '.' . $ this -> getViewSuffix ( ) ; } | Get full name of script to render |
45,885 | public function setData ( array $ data ) { foreach ( $ data as $ name => $ value ) { if ( is_string ( $ name ) ) { $ this -> __set ( $ name , $ value ) ; } } return $ this ; } | Set data collections in View |
45,886 | public function getSenderClass ( $ options ) { if ( empty ( $ options [ 'sender' ] ) ) { if ( function_exists ( 'extension_loaded' ) && extension_loaded ( 'curl' ) && PHP_VERSION_ID >= 50300 ) { return 'Consumerr\Sender\CurlSender' ; } else { return 'Consumerr\Sender\PhpSender' ; } } else { if ( isset ( $ this -> senderAlias [ $ options [ 'sender' ] ] ) ) { return $ this -> senderAlias [ $ options [ 'sender' ] ] ; } else { if ( ! class_exists ( $ options [ 'sender' ] ) ) { throw new AssertionException ( "Sender class {$options['sender']} was not found." ) ; } return $ options [ 'sender' ] ; } } } | Determine sender handler from configuration |
45,887 | public function add ( string $ path , $ callable ) : Route { $ route = new Route ( $ path , $ callable ) ; $ this -> routes [ ] = $ route ; return $ route ; } | Register a new Route |
45,888 | private function configureSlashPrefix ( array $ pieces ) : self { $ first = array_shift ( $ pieces ) ; $ pattern = sprintf ( '#^%s#' , DIRECTORY_SEPARATOR ) ; if ( preg_match ( $ pattern , $ first ) ) { $ this -> prefix .= DIRECTORY_SEPARATOR ; } return $ this ; } | Configura el normalizer para tratar con rutas absolutas |
45,889 | private function getPartsFromSegment ( string $ segment ) : array { $ parts = explode ( DIRECTORY_SEPARATOR , $ segment ) ; return array_filter ( $ parts , function ( $ part ) { return $ this -> isNotEmpty ( $ part ) ; } ) ; } | Separa un segmento en varias partes cortando por DIRECTORY_SEPARATOR |
45,890 | protected function toString ( ) : string { $ normalized = sprintf ( '%s%s' , $ this -> prefix , implode ( DIRECTORY_SEPARATOR , $ this -> stack ) ) ; return trim ( $ normalized ) ; } | Devuelve la ruta normalizada |
45,891 | public function isValidEmail ( string $ email ) : bool { return filter_var ( filter_var ( $ email , FILTER_SANITIZE_EMAIL ) , FILTER_VALIDATE_EMAIL ) !== false ; } | Validate a email address . |
45,892 | public function repl ( ) { $ input = $ this -> prompt ( ) ; $ buffer = null ; while ( $ input != 'exit;' ) { try { $ buffer .= $ input ; if ( ( new ShallowParser ) -> statements ( $ buffer ) ) { ob_start ( ) ; $ app = $ this -> container ; eval ( $ buffer ) ; $ response = ob_get_clean ( ) ; if ( ! empty ( $ response ) ) $ this -> output -> writeln ( trim ( $ response ) ) ; $ buffer = null ; } } catch ( \ Exception $ e ) { $ this -> error ( $ e -> getMessage ( ) ) ; } $ input = $ this -> prompt ( $ buffer !== null ) ; } if ( $ input == 'exit;' ) exit ; } | Run the REPL loop |
45,893 | protected function prompt ( $ indent = false ) { $ dialog = $ this -> getHelperSet ( ) -> get ( 'dialog' ) ; $ indent = $ indent ? '*' : null ; return $ dialog -> ask ( $ this -> output , "<info>encore{$indent}></info>" , null ) ; } | Prompt the user for an input |
45,894 | public function getActualFileDir ( $ filename , $ subDir = self :: UPLOADER_SUB_DIR ) { return $ this -> getPath ( array ( $ this -> getMediaRootDir ( ) , $ subDir , $ this -> getFileDirPrefix ( $ filename ) ) ) ; } | Get actual file dir . |
45,895 | public function getFileDirPrefix ( $ filename ) { if ( empty ( $ filename ) ) { throw new InvalidArgumentException ( 'Invalid filename argument' ) ; } $ path = array ( ) ; $ parts = explode ( '.' , $ filename ) ; for ( $ i = 0 ; $ i < min ( strlen ( $ parts [ 0 ] ) , $ this -> prefixSize ) ; $ i ++ ) { $ path [ ] = $ filename [ $ i ] ; } $ path = $ this -> getPath ( $ path ) ; return $ path ; } | Get file dir prefix . |
45,896 | public function getAbsoluteFilePath ( $ filename , $ subDir = self :: UPLOADER_SUB_DIR ) { return $ this -> getRootDir ( ) . $ this -> getRelativeFilePath ( $ filename , $ subDir ) ; } | Get absolute file path . |
45,897 | public function getRelativeFilePath ( $ filename , $ subDir = self :: UPLOADER_SUB_DIR ) { $ pathParts = array ( Media :: NAME , $ subDir , $ this -> getFileDirPrefix ( $ filename ) , $ filename ) ; return DIRECTORY_SEPARATOR . $ this -> getPath ( $ pathParts ) ; } | Get relative file path . |
45,898 | public function verifyPassword ( $ email , $ password ) { $ this -> find ( "email" , $ email ) ; return password_verify ( $ password , $ this -> password ) ; } | Verify the acronym and the password if successful the object contains all details from the database row . |
45,899 | public function isEmailUnique ( $ email ) { $ this -> find ( "email" , $ email ) ; if ( isset ( $ this -> id ) ) { return false ; } return true ; } | Check whether the user is an Admin |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.