idx int64 0 60.3k | question stringlengths 99 4.85k | target stringlengths 5 718 |
|---|---|---|
9,000 | private function _computeAuthTag ( string $ A , string $ C , string $ J0 , string $ K , GHASH $ ghash ) : string { $ data = self :: _pad128 ( $ A ) . self :: _pad128 ( $ C ) . self :: _uint64 ( strlen ( $ A ) << 3 ) . self :: _uint64 ( strlen ( $ C ) << 3 ) ; $ S = $ ghash ( $ data ) ; return substr ( $ this -> _gctr (... | Compute authentication tag |
9,001 | private static function _pad128 ( $ data ) { $ padlen = 16 - strlen ( $ data ) % 16 ; if ( 16 != $ padlen ) { $ data .= str_repeat ( "\0" , $ padlen ) ; } return $ data ; } | Pad data to 128 bit block boundary . |
9,002 | private static function _inc32 ( string $ X ) : string { $ Y = substr ( $ X , 0 , - 4 ) ; $ n = self :: strToGMP ( substr ( $ X , - 4 ) ) + 1 ; $ Y .= substr ( self :: gmpToStr ( $ n , 4 ) , - 4 ) ; return $ Y ; } | Increment 32 rightmost bits of the counter block . |
9,003 | public static function gmpToStr ( \ GMP $ num , int $ size ) : string { $ data = gmp_export ( $ num , 1 , GMP_MSW_FIRST | GMP_BIG_ENDIAN ) ; $ len = strlen ( $ data ) ; if ( $ len < $ size ) { $ data = str_repeat ( "\0" , $ size - $ len ) . $ data ; } return $ data ; } | Convert GMP number to string . |
9,004 | protected function getMethodAnnotations ( ReflectionClass $ class , SimpleAnnotationReader $ reader ) { $ annotations = [ ] ; foreach ( $ class -> getMethods ( ) as $ method ) { $ results = $ reader -> getMethodAnnotations ( $ method ) ; if ( count ( $ results ) > 0 ) $ annotations [ $ method -> name ] = $ results ; } ... | Get the method annotations for a given class . |
9,005 | public function sendStream ( $ stream , $ name , $ exit = true ) { Header :: sendDownloadDialog ( $ stream , $ name , $ exit ) ; } | Sends a download dialog to the browser . |
9,006 | public function cacheNoValidate ( $ seconds = 60 ) { self :: preventMultipleCaching ( ) ; self :: $ cached = true ; Header :: cacheNoValidate ( $ seconds ) ; return $ this ; } | If you want to allow a page to be cached by shared proxies for one minute . |
9,007 | public function getIp ( ) { if ( $ this -> X_FORWARDED_FOR ) { return $ this -> X_FORWARDED_FOR ; } if ( $ this -> CLIENT_IP ) { return $ this -> CLIENT_IP ; } if ( $ this -> SERVER_NAME ) { return gethostbyname ( $ this -> SERVER_NAME ) ; } return $ this -> REMOTE_ADDR ; } | Get remote IP |
9,008 | public function getUserAgent ( ) { if ( $ this -> USER_AGENT ) { return $ this -> USER_AGENT ; } if ( $ this -> HTTP_USER_AGENT ) { return $ this -> HTTP_USER_AGENT ; } return null ; } | Get User Agent |
9,009 | public function getUrl ( ) { $ protocol = strpos ( strtolower ( $ this -> PATH_INFO ) , 'https' ) === false ? 'http' : 'https' ; return $ protocol . '://' . $ this -> getHost ( ) ; } | Gives you the current page URL |
9,010 | public function getRequestHeader ( $ header ) { $ header = str_replace ( '-' , '_' , strtoupper ( $ header ) ) ; $ value = $ this -> { 'HTTP_' . $ header } ; if ( ! $ value ) { $ headers = $ this -> getRequestHeaders ( ) ; $ value = ! empty ( $ headers [ $ header ] ) ? $ headers [ $ header ] : null ; } return $ value ;... | Try to get a request header . |
9,011 | public function getRequestHeaders ( ) { $ headers = array ( ) ; foreach ( $ this -> data -> getAll ( ) as $ key => $ value ) { if ( 'HTTP_' === substr ( $ key , 0 , 5 ) ) { $ headers [ substr ( $ key , 5 ) ] = $ value ; } } return $ headers ; } | Try to determine all request headers |
9,012 | public static function is_event_request ( $ requestData = null , $ contentTypes = null ) { if ( ! $ requestData ) { $ requestData = $ _SERVER ; } if ( ! $ contentTypes ) { $ contentTypes = static :: $ eventContentTypes ; } switch ( false ) { case isset ( $ requestData [ 'REQUEST_METHOD' ] ) : case $ requestData [ 'REQU... | Determines if the request is an event notification and returns the corresponding format identifier . |
9,013 | public function handlePasswordChangeSuccess ( FOSFormEvent $ event ) { $ form = $ event -> getForm ( ) ; $ user = $ form -> getData ( ) ; if ( $ user instanceof PKEncryptionEnabledUserInterface ) { $ currentPassword = $ form -> get ( 'current_password' ) -> getData ( ) ; $ this -> encryptionService -> handleUserPasswor... | Handles a successful password change using the FOSUserBundle forms |
9,014 | public function handlePasswordResetSuccess ( FOSFormEvent $ event ) { $ form = $ event -> getForm ( ) ; $ user = $ form -> getData ( ) ; if ( $ user instanceof PKEncryptionEnabledUserInterface ) { $ this -> encryptionService -> handleUserPasswordResetSuccess ( $ user ) ; } } | Handles a successful password reset using the FOSUserBundle forms |
9,015 | public function handleUserRegistrationSuccess ( FOSFormEvent $ event ) { $ user = $ event -> getForm ( ) -> getData ( ) ; if ( $ user instanceof PKEncryptionEnabledUserInterface ) { $ this -> encryptionService -> handleUserPreCreation ( $ user ) ; } } | Handles a successful user registration using the FOSUserBundle forms |
9,016 | public function handleUserRegistrationComplete ( FOSFilterUserResponseEvent $ event ) { $ user = $ event -> getUser ( ) ; if ( $ user instanceof PKEncryptionEnabledUserInterface ) { $ this -> encryptionService -> handleUserPostCreation ( $ user ) ; } } | Handles the completion of a user registration using the FOSUserBundle forms |
9,017 | public static function factory ( string $ role , string $ text ) : Word { $ instance = new static ( ) ; $ instance -> role = $ role ; $ instance -> text = $ text ; return $ instance ; } | Creates a word element with the given data as attributes . |
9,018 | public function getSystemKey ( ) { return isset ( $ this -> encryptedKeys [ self :: SYSTEM_IDENTIFIER ] ) ? $ this -> encryptedKeys [ self :: SYSTEM_IDENTIFIER ] : null ; } | Returns the encrypted key that corresponds to the system master key |
9,019 | public function addKey ( PKEncryptionEnabledUserInterface $ user , $ encryptedKey ) { $ userClass = $ this -> getUserClass ( $ user ) ; $ userId = $ user -> getId ( ) ; if ( ! isset ( $ this -> encryptedKeys [ $ userClass ] ) ) { $ this -> encryptedKeys [ $ userClass ] = array ( ) ; } $ this -> encryptedKeys [ $ userCl... | Adds a new version of the key encrypted with the key of a new user |
9,020 | public function getKey ( PKEncryptionEnabledUserInterface $ user ) { $ userClass = $ this -> getUserClass ( $ user ) ; $ userId = $ user -> getId ( ) ; return isset ( $ this -> encryptedKeys [ $ userClass ] ) && isset ( $ this -> encryptedKeys [ $ userClass ] [ $ userId ] ) ? $ this -> encryptedKeys [ $ userClass ] [ $... | Returns the encrypted key that corresponds to a determined user |
9,021 | public static function factory ( $ storage ) { switch ( $ storage ) { case 'apc' : return new Storage \ Apc ( Cache :: storage ( 'apc' ) ) ; case 'cookie' : return new Storage \ Cookie ( ) ; case 'file' : return new Storage \ File ( Config :: get ( 'session.storage_path' ) ) ; case 'pdo' : return new Storage \ Pdo ( Pd... | Create a new session storage instance . |
9,022 | public function readDouble ( ) { $ double = $ this -> readRawBytes ( 8 ) ; if ( Spec :: isLittleEndian ( ) ) { $ double = strrev ( $ double ) ; } $ double = unpack ( "d" , $ double ) ; return $ double [ 1 ] ; } | Read a byte as a float |
9,023 | public function content ( ) : array { $ dirs = collect ( $ this -> storage -> allDirectories ( $ this -> root ) ) ; $ output = [ ] ; $ dirs -> filter ( function ( $ dir ) { $ parts = $ this -> split ( $ dir ) ; return ! in_array ( $ parts [ 0 ] , $ this -> exclude ) ; } ) -> each ( function ( $ dir ) use ( & $ output )... | Gets root folder tree content . |
9,024 | private function dirToPath ( string $ dir ) : string { if ( $ this -> root !== '' ) { return str_replace_first ( $ this -> root , '' , $ dir ) ; } return $ dir ; } | Convert dir to path . |
9,025 | private function split ( string $ dir ) : array { $ path = $ this -> dirToPath ( $ dir ) ; return explode ( '/' , Str :: normalizePath ( $ path ) ) ; } | Normalize and split dir path . |
9,026 | public static function getMaxFilesize ( ) { $ max = trim ( ini_get ( 'upload_max_filesize' ) ) ; if ( '' === $ max ) { return PHP_INT_MAX ; } $ unit = strtolower ( substr ( $ max , - 1 ) ) ; $ max = ( int ) substr ( $ max , 0 , - 1 ) ; if ( in_array ( $ unit , array ( 'g' , 'm' , 'k' ) , true ) ) { $ max *= 1024 ; } re... | Returns the maximum size of an uploaded file in bytes as configured in php . ini |
9,027 | protected function getDatabaseConfigs ( array & $ return ) { $ return [ 'localhost' ] = 'localhost' ; $ return [ 'host' ] = $ this -> connection -> getConfig ( 'host' ) ; $ return [ 'database' ] = $ this -> connection -> getConfig ( 'database' ) ; $ return [ 'username' ] = $ this -> connection -> getConfig ( 'username'... | Get database config . |
9,028 | protected function generateConsoleCommand ( $ results , $ full = false ) { return sprintf ( "mysql -u\"%s\" -p\"%s\" -h\"%s\" -e\"%s\"" , $ results [ 'connection_username' ] , $ full ? $ results [ 'connection_password' ] : '******' , $ results [ 'host' ] , join ( ' ' , $ results [ 'commands' ] ) ) ; } | Generate terminal command . |
9,029 | public static function fire ( $ events , $ parameters = array ( ) , $ halt = false ) { $ responses = array ( ) ; $ parameters = ( array ) $ parameters ; foreach ( ( array ) $ events as $ event ) { if ( static :: listeners ( $ event ) ) { foreach ( static :: $ events [ $ event ] as $ callback ) { $ response = call_user_... | Fire an event so that all listeners are called . |
9,030 | protected function makeDir ( $ path ) { if ( ! file_exists ( dirname ( $ path ) ) ) { $ this -> makeDir ( dirname ( $ path ) ) ; } if ( ! file_exists ( $ path ) ) { mkdir ( $ path ) ; } } | Creates a directory recursively iterating through and creating missing parent directories |
9,031 | public function render ( ) { if ( Sapi :: isCli ( ) && Config :: get ( 'environment' ) == 'production' ) { $ suffix = 'CliAction' ; $ action = $ this -> request -> fromCli ( ) -> get ( 'action' , 'index' ) ; } else { $ suffix = 'Action' ; if ( $ this -> request -> getMethod ( ) != 'GET' && $ this -> request -> getMetho... | Method to show the content . |
9,032 | public function redirect ( $ route , $ permanent = false , $ exit = true ) { $ url = Url :: compute ( $ route ) ; ( $ permanent === true ) ? Header :: sendMovedPermanently ( ) : Header :: sendFound ( ) ; Header :: toLocation ( $ url , $ exit ) ; } | Prepares the response object to return an HTTP Redirect response to the client . |
9,033 | public static function isWeb ( ) { return self :: isApache ( ) || self :: isIIS ( ) || self :: isCgi ( ) || self :: isBuiltInWebServer ( ) || self :: isHHVM ( ) ; } | Are we in a web environment? |
9,034 | public function getConfig ( $ type = self :: CONFIG_ALL ) { if ( $ type == self :: CONFIG_ALL ) { return $ this -> config ; } return isset ( $ this -> config [ $ type ] ) ? $ this -> config [ $ type ] : [ ] ; } | Returns all config array or specific one . |
9,035 | protected function isNotRequiredAndEmpty ( $ type = 'var' ) { $ condition = false ; if ( $ type == 'var' ) { $ condition = strlen ( $ this -> params [ 1 ] ) == 0 ; } elseif ( $ type == 'file' ) { $ fieldsName = $ this -> params [ 0 ] ; $ condition = isset ( $ _FILES [ $ fieldsName ] [ 'name' ] ) && $ _FILES [ $ fieldsN... | Check if variable is not required - to prevent error messages from another validators . |
9,036 | public function setPath ( $ path = '' ) { $ userFolder = Str :: normalizePath ( config ( 'cripfilesys.user_folder' ) ) ; if ( $ userFolder !== '' && ! starts_with ( $ path , $ userFolder ) ) { $ path = empty ( $ path ) ? '' : $ path ; $ path = $ this -> prefixPath ( $ path , $ userFolder ) ; } $ this -> path = Str :: n... | Set current blob path property . |
9,037 | public function getMediaType ( ) { $ mime = $ this -> getMime ( ) ; if ( $ mime == 'file' ) { return $ mime ; } foreach ( $ this -> package -> config ( 'mime.media' ) as $ mediaType => $ mimes ) { if ( in_array ( $ mime , $ mimes ) ) { return $ mediaType ; } } return 'dir' ; } | Get blob media type . |
9,038 | public function getThumbUrl ( $ size = 'thumb' ) { $ url = $ this -> package -> config ( 'icons.url' ) ; $ icons = $ this -> package -> config ( 'icons.files' ) ; if ( ! $ this -> metadata -> isFile ( ) ) { return $ url . $ icons [ 'dir' ] ; } if ( $ this -> isImage ( ) ) { $ thumbs = $ this -> getThumbsDetails ( ) ; i... | Get thumb size thumbnail url . |
9,039 | public function getUrl ( $ path = null ) { $ path = $ path ? : $ this -> path ; if ( $ this -> package -> config ( 'public_storage' , false ) ) { try { $ useAbsolute = $ this -> package -> config ( 'absolute_url' , false ) ; $ absolute = $ this -> storage -> url ( $ path ) ; if ( $ useAbsolute ) return $ absolute ; $ r... | Generates url to a file . |
9,040 | public function getMime ( ) { if ( $ this -> metadata -> isFile ( ) ) { $ mimes = $ this -> package -> config ( 'mime.types' ) ; foreach ( $ mimes as $ mime => $ mimeValues ) { $ key = collect ( $ mimeValues ) -> search ( function ( $ mimeValue ) { return preg_match ( $ mimeValue , $ this -> metadata -> getMimeType ( )... | Get blob mime . |
9,041 | private function isImage ( ) { if ( $ this -> metadata -> isFile ( ) && mb_strpos ( $ this -> metadata -> getMimeType ( ) , 'image/' ) === 0 ) { return true ; } return false ; } | Determines is the current blob an image . |
9,042 | private function setThumbsDetails ( ) { $ this -> thumbsDetails = [ ] ; if ( $ this -> isImage ( ) ) { $ service = new ThumbService ( $ this -> package ) ; collect ( $ service -> getSizes ( ) ) -> each ( function ( $ size , $ key ) { $ this -> thumbsDetails [ $ key ] = [ 'size' => $ key , 'width' => $ size [ 0 ] , 'hei... | Set thumb sizes details for current file . |
9,043 | protected function loadAnnotatedRoutes ( ) { if ( $ this -> app -> environment ( 'local' ) && $ this -> scanWhenLocal ) { $ this -> scanRoutes ( ) ; } if ( ! empty ( $ this -> scanRoutes ) && $ this -> finder -> routesAreScanned ( ) ) { $ this -> loadScannedRoutes ( ) ; } } | Load the annotated routes |
9,044 | public function messages ( $ field = '' ) { if ( $ field ) { return isset ( $ this -> errorMessages [ $ field ] ) ? $ this -> errorMessages [ $ field ] : [ ] ; } $ messages = [ ] ; array_walk_recursive ( $ this -> errorMessages , function ( $ message ) use ( & $ messages ) { $ messages [ ] = $ message ; } ) ; return $ ... | Get flat messages array or all messages from field . |
9,045 | public function firsts ( ) { $ messages = [ ] ; foreach ( $ this -> errorMessages as $ fieldsMessages ) { foreach ( $ fieldsMessages as $ fieldMessage ) { $ messages [ ] = $ fieldMessage ; break ; } } return $ messages ; } | For each rule get it s first message . |
9,046 | public function isPerUserEncryptionEnabled ( ) { $ perUserEncryptionEnabled = false ; if ( $ this -> settings [ 'per_user_encryption_enabled' ] ) { $ encryptionMetadata = $ this -> metadataFactory -> getAllMetadata ( ) ; foreach ( $ encryptionMetadata as $ classEncryptionMetadata ) { if ( self :: MODE_PER_USER_SHAREABL... | Checks if the Per User Encryption must be enabled |
9,047 | public function getEncryptionEnabledEntitiesMetadata ( ) { $ entityManager = $ this -> doctrine -> getManager ( ) ; $ doctrineMetadataFactory = $ entityManager -> getMetadataFactory ( ) ; $ encryptedEnabledTypes = array ( ) ; $ encryptionMetadata = $ this -> metadataFactory -> getAllMetadata ( ) ; foreach ( $ encryptio... | Returns the doctrine metadata of all the encryption enabled entities |
9,048 | public function addEncryptionMetadata ( DoctrineClassMetadata $ metadata ) { if ( $ metadata -> isMappedSuperclass ) { return ; } $ reflection = $ metadata -> getReflectionClass ( ) ; if ( $ this -> hasEncryptionEnabled ( $ reflection ) && ! $ this -> hasEncryptionFieldsDoctrineMetadata ( $ metadata ) ) { $ metadata ->... | Adds the metadata required to encrypt the doctrine entity |
9,049 | public function processEntityPostPersist ( $ entity ) { $ userClasses = $ this -> settings [ 'user_classes' ] ; foreach ( $ userClasses as $ userClass ) { if ( class_exists ( $ userClass ) && $ entity instanceof $ userClass ) { $ relatedEntities = $ this -> getUserRelatedEntities ( $ entity ) ; foreach ( $ relatedEntit... | Process all encryption related actions on an Entity post persist event |
9,050 | public function processEntityMigration ( $ entity ) { if ( $ entity ) { $ reflection = ClassUtils :: newReflectionObject ( $ entity ) ; if ( $ this -> hasEncryptionEnabled ( $ reflection ) && ! $ entity -> isEncrypted ( ) ) { $ encryptionEnabledFields = $ this -> getEncryptionEnabledFields ( $ reflection ) ; foreach ( ... | Normalizes the data of the entity fields to the one required by the encryption after the encryption has been activated |
9,051 | private function isEncryptableFile ( $ entity ) { $ reflection = ClassUtils :: newReflectionObject ( $ entity ) ; $ classMetadata = $ this -> getEncryptionMetadataFor ( $ reflection -> getName ( ) ) ; return $ classMetadata -> encryptionEnabled && $ classMetadata -> encryptedFile ; } | Checks if the entity has file encryption enabled |
9,052 | private function processEntity ( $ entity , $ operation ) { if ( $ this -> settings [ $ operation . '_on_backend' ] ) { $ reflection = ClassUtils :: newReflectionObject ( $ entity ) ; $ classMetadata = $ this -> getEncryptionMetadataFor ( $ reflection -> getName ( ) ) ; if ( $ classMetadata -> encryptionEnabled && $ th... | Processes an entity if it has encryption enabled and it s not already processed |
9,053 | private function encryptFile ( EncryptableFile $ fileEntity , KeyData $ keyData ) { $ file = $ fileEntity -> getFile ( ) ; $ encrypt = false ; if ( $ file ) { $ filePath = $ file -> getRealPath ( ) ; $ encrypt = true ; } elseif ( $ fileEntity -> getId ( ) && $ fileEntity -> fileExists ( ) && ! $ fileEntity -> isFileEnc... | Encrypts the uploaded file contained in a File Entity |
9,054 | private function decryptFile ( $ fileEntity , KeyData $ keyData ) { if ( $ keyData ) { $ encryptedContent = $ fileEntity -> getContent ( ) ; if ( $ encryptedContent ) { $ encType = CryptographyProviderInterface :: FILE_ENCRYPTION ; $ decryptedContent = $ this -> cryptographyProvider -> decrypt ( $ encryptedContent , $ ... | Decrpyts the content of a file associated with an Encryptable File Entity |
9,055 | public function hasEncryptionEnabled ( \ ReflectionClass $ reflection , DoctrineClassMetadata $ metadata = null ) { $ classMetadata = $ this -> getEncryptionMetadataFor ( $ reflection -> getName ( ) ) ; return $ classMetadata -> encryptionEnabled ; } | Checks if the class has been enabled for encryption |
9,056 | private function hasFileEncryptionEnabled ( \ ReflectionClass $ reflection ) { $ classMetadata = $ this -> getEncryptionMetadataFor ( $ reflection -> getName ( ) ) ; return $ classMetadata -> encryptionEnabled && $ classMetadata -> encryptedFile ; } | Checks if the class is a File entity and has the file encryption enabled |
9,057 | private function keyPerEntityRequired ( \ ReflectionClass $ reflectionClass ) { $ classMetadata = $ this -> getEncryptionMetadataFor ( $ reflectionClass -> getName ( ) ) ; $ keyPerEntityModes = array ( EncryptionService :: MODE_PER_USER_SHAREABLE , EncryptionService :: MODE_SYSTEM_ENCRYPTION , ) ; return $ classMetadat... | Checks if the entity needs a field to store a key for each instance |
9,058 | public function getEncryptionEnabledFields ( \ ReflectionClass $ reflectionClass ) { $ encryptionEnabledFields = array ( ) ; $ classMetadata = $ this -> getEncryptionMetadataFor ( $ reflectionClass -> getName ( ) ) ; if ( $ classMetadata -> encryptionEnabled ) { foreach ( $ classMetadata -> propertyMetadata as $ proper... | Checks the fields of the entity and returns a list of those with encryption enabled |
9,059 | private function getFieldValue ( $ entity , \ ReflectionProperty $ reflectionProperty ) { $ value = null ; if ( $ reflectionProperty ) { $ reflectionProperty -> setAccessible ( true ) ; $ value = $ reflectionProperty -> getValue ( $ entity ) ; } return $ value ; } | Returns the value of an entity using reflection |
9,060 | private function setFieldValue ( $ entity , \ ReflectionProperty $ reflectionProperty , $ value ) { if ( $ reflectionProperty ) { $ reflectionProperty -> setAccessible ( true ) ; $ value = $ reflectionProperty -> setValue ( $ entity , $ value ) ; } } | Sets the value of an entity using reflection |
9,061 | private function getEncryptedFieldMapping ( array $ fieldMapping ) { switch ( $ fieldMapping [ 'type' ] ) { case 'string' : return new FieldMapping \ StringFieldMapping ( $ this , $ fieldMapping ) ; case 'text' : case 'json_array' : case 'simple_array' : case 'array' : case 'object' : return new FieldMapping \ TextFiel... | Factory method to get the right EncryptedFieldMapping object for a determined field |
9,062 | private function getFieldEncrypter ( \ ReflectionProperty $ reflectionProperty , \ ReflectionClass $ reflectionClass ) { $ classMetadata = $ this -> doctrine -> getManager ( ) -> getMetadataFactory ( ) -> getMetadataFor ( $ reflectionClass -> getName ( ) ) ; $ fieldName = $ reflectionProperty -> getName ( ) ; $ fieldMa... | Factory method to get the right EncryptedFieldEncrypter object for a determined field |
9,063 | private function getFieldNormalizer ( \ ReflectionProperty $ reflectionProperty , \ ReflectionClass $ reflectionClass ) { $ classMetadata = $ this -> doctrine -> getManager ( ) -> getMetadataFactory ( ) -> getMetadataFor ( $ reflectionClass -> getName ( ) ) ; $ fieldName = $ reflectionProperty -> getName ( ) ; $ fieldM... | Factory method to get the right EncryptedFieldNormalizer object for a determined field |
9,064 | private function getUserRelatedEntities ( $ user ) { $ relatedEntities = array ( ) ; $ reflectionClass = ClassUtils :: newReflectionObject ( $ user ) ; if ( $ reflectionClass -> hasMethod ( 'getMainProfile' ) ) { $ userProfile = $ user -> getMainProfile ( ) ; $ relatedEntities = $ userProfile ? array ( $ userProfile ) ... | Returns the entities that are related with the user entity and can be persisted in the same moment as the user entity . For this entities the user id is not set in the moment they are persisted and therefore not saved with the key |
9,065 | private function hasEncryptionFieldsDoctrineMetadata ( DoctrineClassMetadata $ classMetadata ) { $ return = false ; if ( ClassMetadataInfo :: INHERITANCE_TYPE_JOINED === $ classMetadata -> inheritanceType || ClassMetadataInfo :: INHERITANCE_TYPE_SINGLE_TABLE === $ classMetadata -> inheritanceType ) { $ rootEntity = $ c... | Checks if the required fields metadata were inserted in some other class of the hierachy . |
9,066 | private static function getNodeId ( ) { if ( self :: $ hostIp !== null ) { return ip2long ( self :: $ hostIp ) ; } self :: $ hostIp = '127.0.0.1' ; if ( self :: $ hostName !== null ) { self :: $ hostIp = crc32 ( self :: $ hostName ) ; } if ( true === function_exists ( 'php_uname' ) ) { self :: $ hostName = php_uname ( ... | Returns a 32 - bit integer that identifies this host . |
9,067 | public static function generate ( ) { if ( self :: $ node === null ) { self :: $ node = self :: getNodeId ( ) ; } if ( self :: $ pid === null ) { self :: $ pid = self :: getLockId ( ) ; } list ( $ time_mid , $ time_lo ) = explode ( ' ' , microtime ( ) ) ; $ time_low = ( int ) $ time_lo ; $ time_mid = ( int ) substr ( $... | Generate an RFC 4122 UUID . |
9,068 | protected function getTraversableSplos ( \ SplObjectStorage $ splos ) { if ( $ this -> walking -> contains ( $ splos ) ) { return clone $ splos ; } else { $ this -> walking -> attach ( $ splos ) ; return $ splos ; } } | Helper function to ensure SPLOS traversal pointer is not overridden . |
9,069 | public static function factory ( string $ src ) : Audio { $ audio = new Audio ( ) ; $ audio -> src = $ src ; return $ audio ; } | Creates an audio element with the given src as attribute . |
9,070 | public function read ( $ prompt , $ validation = "/.*/" ) { $ value = '' ; while ( true ) { $ this -> view ( "Please enter a " . $ prompt . ":" ) ; $ value = $ this -> value ( ) ; if ( $ this -> valid ( $ validation , $ value ) ) { break ; } $ this -> view ( "[ Value format for " . $ prompt . " is invalid! ]" ) ; } ret... | Allow direct access to the corresponding input stream of the PHP process . |
9,071 | public static function make ( array $ data , array $ rules , array $ userMessages = [ ] ) { self :: $ validatorFacade = new ValidatorFacade ( $ userMessages ) ; $ data = self :: prepareData ( $ data ) ; $ rules = self :: prepareRules ( $ rules ) ; foreach ( $ rules as $ fieldName => $ fieldRules ) { $ fieldName = trim ... | Make validation . |
9,072 | private static function prepareData ( array $ data ) { $ newData = [ ] ; foreach ( $ data as $ paramName => $ paramValue ) { if ( is_array ( $ paramValue ) ) { foreach ( $ paramValue as $ newKey => $ newValue ) { $ newData [ trim ( $ paramName ) . '[' . trim ( $ newKey ) . ']' ] = trim ( $ newValue ) ; } } else { $ new... | Prepare user data for validator . |
9,073 | private static function prepareRules ( array $ rules ) { $ mergedRules = [ ] ; foreach ( $ rules as $ ruleFields => $ ruleConditions ) { if ( strpos ( $ ruleFields , ',' ) !== false ) { foreach ( explode ( ',' , $ ruleFields ) as $ fieldName ) { $ fieldName = trim ( $ fieldName ) ; if ( ! isset ( $ mergedRules [ $ fiel... | Merges all field s rules into one if you have elegant implementation you are welcome . |
9,074 | public static function base ( ) { if ( isset ( static :: $ base ) ) { return static :: $ base ; } $ url = Config :: get ( 'app.url' ) ; if ( $ url !== '' ) { $ base = $ url ; } else { $ base = self :: $ url ; } return static :: $ base = $ base ; } | Get the base URL of the application . |
9,075 | public static function to ( $ url = '' , $ https = null , $ asset = false ) { $ url = trim ( $ url , '/' ) ; if ( static :: valid ( $ url ) ) { return $ url ; } $ root = self :: format ( $ https , $ asset ) ; return rtrim ( $ root , '/' ) . '/' . ltrim ( $ url , '/' ) ; } | Generate an application URL . |
9,076 | private static function format ( $ https = null , $ asset = false ) { $ root = static :: base ( ) ; if ( ! $ asset ) { $ root .= '/' . Config :: get ( 'app.index' ) ; } if ( is_null ( $ https ) ) { $ https = self :: $ isHttps ; } if ( $ https && Config :: get ( 'ssl' ) ) { return preg_replace ( '~http://~' , 'https://'... | Computes the URl method |
9,077 | public static function toAsset ( $ url , $ https = null ) { if ( static :: valid ( $ url ) || static :: valid ( 'http:' . $ url ) ) { return $ url ; } $ app = Config :: get ( 'app' ) ; $ root = ( $ app [ 'asset_url' ] != '' ) ? $ app [ 'asset_url' ] : false ; if ( $ root ) { return rtrim ( $ root , '/' ) . '/' . ltrim ... | Generate an application URL to an asset . |
9,078 | public static function valid ( $ url ) { if ( Str :: startsWith ( $ url , '//' ) ) { return true ; } return filter_var ( $ url , FILTER_VALIDATE_URL ) !== false ; } | Determine if the given URL is valid . |
9,079 | public function id ( ) { if ( $ this instanceof \ Pimf \ Session \ Storages \ Cookie ) { return Character :: random ( 40 ) ; } do { $ session = $ this -> load ( $ key = Character :: random ( 40 ) ) ; } while ( $ session !== null ) ; return $ key ; } | Get a new session ID that isn t assigned to any current session . |
9,080 | protected function updateRuleProperty ( $ rule , $ key , $ value ) { if ( preg_match ( '/^[^.]+(\.[^.]+){3}$/' , $ rule ) ) { $ this -> current [ $ rule ] [ $ key ] = $ value ; $ this -> commit ( ) ; } else { throw new InvalidArgumentException ( 'Invalid rule name!' ) ; } } | Update a property of a rule . |
9,081 | protected function updateSniffProperty ( $ sniff , $ key , $ value ) { if ( preg_match ( '/^[^.]+(\.[^.]+){2}$/' , $ sniff ) ) { $ this -> current [ $ sniff ] [ 'properties' ] [ $ key ] = $ value ; $ this -> commit ( ) ; } else { throw new InvalidArgumentException ( 'Invalid sniff name!' ) ; } } | Update a property of a sniff . |
9,082 | public function duplicate ( string $ id = null ) : ResourceInterface { $ resource = new self ( $ this -> type ( ) , $ id ?? $ this -> id ( ) , $ this -> attributes ( ) -> all ( ) ) ; $ resource -> metaInformation ( ) -> mergeCollection ( $ this -> metaInformation ( ) ) ; foreach ( $ this -> relationships ( ) -> all ( )... | Creates a new resource containing all data from the current one . If set the new request will have the given id . |
9,083 | protected function registerExecutor ( ) { $ this -> app -> singleton ( 'backup.executor' , function ( Container $ app ) { $ logger = $ app [ 'log' ] ; return new Executor ( $ logger ) ; } ) ; $ this -> app -> alias ( 'backup.executor' , Executor :: class ) ; } | Register the executor class . |
9,084 | protected function registerProfileBuilder ( ) { $ this -> app -> singleton ( 'backup.builder' , function ( Container $ app ) { $ config = $ app [ 'config' ] [ 'backup' ] ; $ factory = new ProfileBuilderFactory ( $ app ) ; return $ factory -> make ( $ config ) ; } ) ; $ this -> app -> alias ( 'backup.builder' , ProfileB... | Register the profile builder class . |
9,085 | protected function registerProfileRegistry ( ) { $ this -> app -> singleton ( 'backup.registry' , function ( Container $ app ) { $ config = $ app [ 'config' ] [ 'backup' ] ; $ builder = $ app [ 'backup.builder' ] ; $ factory = new ProfileRegistryFactory ( $ builder ) ; return $ factory -> make ( $ config ) ; } ) ; $ th... | Register the profile registry class . |
9,086 | protected function registerMysqlDumpSource ( ) { $ this -> app -> bind ( MysqlDumpSource :: class , function ( Container $ app ) { $ config = $ app [ 'config' ] ; return new MysqlDumpSource ( $ config ) ; } ) ; } | Register the database source class . |
9,087 | protected function registerBackup ( ) { $ this -> app -> singleton ( 'backup' , function ( Container $ app ) { $ config = $ app [ 'config' ] ; $ registry = $ app [ 'backup.registry' ] ; $ executor = $ app [ 'backup.executor' ] ; return new Backup ( $ config , $ registry , $ executor ) ; } ) ; $ this -> app -> alias ( '... | Register the backup class . |
9,088 | public static function getResourceValidationProfile ( $ descriptor ) { $ descriptor = Utils :: objectify ( $ descriptor ) ; if ( isset ( $ descriptor -> profile ) && $ descriptor -> profile != 'default' ) { return $ descriptor -> profile ; } else { return 'data-resource' ; } } | get the profile which should be used for validation from the given resource descriptor . |
9,089 | public static function getJsonSchemaFile ( $ profile ) { foreach ( static :: getAllSchemas ( ) as $ schema ) { if ( $ schema -> id != 'registry' && $ schema -> id == $ profile ) { if ( isset ( $ schema -> schema_path ) ) { return realpath ( dirname ( __FILE__ ) ) . '/Validators/schemas/' . $ schema -> schema_path ; } e... | given a normalized profile - get the corresponding schema file for known schema in the registry returns false in case of unknown schema works the same for both datapackage schema and resource schemas . |
9,090 | public static function getAllSchemas ( ) { $ registrySchemaFilename = dirname ( __FILE__ ) . '/Validators/schemas/registry.json' ; $ registry = [ ( object ) [ 'id' => 'registry' , 'schema' => 'https://specs.frictionlessdata.io/schemas/registry.json' , 'schema_path' => 'registry.json' , ] , ] ; $ schemaIds = [ ] ; if ( ... | returns array of all known schemas in the registry . |
9,091 | public function rewind ( ) { $ this -> dataStreams = null ; $ this -> currentDataStream = 0 ; foreach ( $ this -> dataStreams ( ) as $ dataStream ) { $ dataStream -> rewind ( ) ; } } | standard iterator functions - to iterate over the data sources |
9,092 | public static function normalizeDataSource ( $ dataSource , $ basePath = null ) { if ( ! empty ( $ basePath ) && ! Utils :: isHttpSource ( $ dataSource ) ) { $ absPath = $ basePath . DIRECTORY_SEPARATOR . $ dataSource ; if ( file_exists ( $ absPath ) ) { $ dataSource = $ absPath ; } } return $ dataSource ; } | allows extending classes to add custom sources used by unit tests to add a mock http source . |
9,093 | protected function getValidationSchemaUrl ( ) { $ profile = $ this -> getValidationProfile ( ) ; if ( $ filename = $ this -> getJsonSchemaFileFromRegistry ( $ profile ) ) { return $ this -> convertValidationSchemaFilenameToUrl ( $ filename ) ; } elseif ( Utils :: isHttpSource ( $ profile ) ) { return $ profile ; } else... | get the url which the schema for validation can be fetched from . |
9,094 | protected function addError ( $ code , $ extraDetails = null ) { $ errorClass = $ this -> getSchemaValidationErrorClass ( ) ; $ this -> errors [ ] = new $ errorClass ( $ code , $ extraDetails ) ; } | Add an error to the validator object - errors are aggregated and returned by validate function . |
9,095 | public function root ( ) : ContainerElement { if ( $ this instanceof Speak ) { return $ this ; } $ currentParent = $ this -> parent ; while ( $ currentParent -> parent !== null ) { $ currentParent = $ currentParent -> parent ; } return $ currentParent ; } | Gets the topmost root element of the current ssml - tree . |
9,096 | public function attr ( string $ name , string $ value = null ) { if ( $ value === null ) { if ( isset ( $ this -> customAttributes [ $ name ] ) ) { return $ this -> customAttributes [ $ name ] ; } throw new SsmlException ( 'Unknown attribute ' . $ name . ' in class ' . get_class ( $ this ) ) ; } $ this -> customAttribu... | Adds an unmanaged custom attribute to the element or gets an attribute either from the list of custom attributes . |
9,097 | protected function customAttributesToDOM ( \ DOMElement $ element ) : void { foreach ( $ this -> customAttributes as $ key => $ value ) { $ element -> setAttribute ( $ key , $ value ) ; } } | Sets the custom attributes in the given \ DomElement instance . |
9,098 | public function make ( array $ config ) : ProfileBuilder { $ config = $ this -> getConfig ( $ config ) ; return $ this -> getProfileBuilder ( $ config ) ; } | Make the profile builder . |
9,099 | protected function getProfileBuilder ( array $ config ) : ProfileBuilder { return new ProfileBuilder ( $ this -> bootstrap ( array_get ( $ config , 'processors' ) ) , $ this -> bootstrap ( array_get ( $ config , 'namers' ) ) , $ this -> bootstrap ( array_get ( $ config , 'sources' ) ) , $ this -> bootstrap ( array_get ... | Get the profile builder . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.