idx int64 0 60.3k | question stringlengths 99 4.85k | target stringlengths 5 718 |
|---|---|---|
53,900 | public static function Read ( string $ package , string $ file , string $ message = null , int $ code = \ E_USER_ERROR , \ Throwable $ previous = null ) : FileAccessError { return new FileAccessError ( $ package , $ file , static :: ACCESS_READ , $ message , $ code , $ previous ) ; } | Init s a new \ Beluga \ IO \ FileAccessError for file read mode . |
53,901 | public static function Write ( string $ package , string $ file , string $ message = null , int $ code = \ E_USER_ERROR , \ Throwable $ previous = null ) : FileAccessError { return new FileAccessError ( $ package , $ file , static :: ACCESS_WRITE , $ message , $ code , $ previous ) ; } | Init s a new \ Beluga \ IO \ FileAccessError for file write mode . |
53,902 | public function getDiscriminatedClass ( PropertyMetadata $ mapping , $ discriminator = null ) { if ( $ discriminator === null ) { $ discriminator = $ mapping -> discriminatorDefaultValue ; } if ( $ discriminator !== null ) { if ( isset ( $ mapping -> discriminatorMap [ $ discriminator ] ) ) { $ discriminator = $ mappin... | Get the class metadata for an association s target with respect to any discriminator value . |
53,903 | public function setPolicy ( string $ policy ) { if ( ! in_array ( $ policy , [ self :: POLICY_NONE , self :: POLICY_ALLOW , self :: POLICY_DENY ] ) ) { throw new Exception ( 'Unsupported policy type: ' . $ policy ) ; } $ this -> policy = $ policy ; $ this -> init ( ) ; } | Set policy . |
53,904 | public function getIdRoleByName ( string $ name ) : string { if ( isset ( $ this -> role [ $ name ] ) ) { return ( string ) $ this -> role [ $ name ] [ 'id' ] ; } return '' ; } | Get id role by name . |
53,905 | public function getResource ( string $ id = null ) : array { if ( $ id ) { if ( is_numeric ( $ id ) ) { $ filter = array_filter ( $ this -> resource , function ( $ row ) use ( $ id ) { return $ row [ 'id' ] == $ id ; } ) ; return ( array ) array_pop ( $ filter ) ; } return ( array ) ( $ this -> resource [ $ id ] ?? [ ]... | Get resource . |
53,906 | public function getIdResourceByName ( string $ name ) : string { if ( isset ( $ this -> resource [ $ name ] ) ) { return ( string ) $ this -> resource [ $ name ] [ 'id' ] ; } return '' ; } | Get id resource by name . |
53,907 | public function getPrivilege ( string $ id = null ) : array { if ( $ id ) { if ( is_numeric ( $ id ) ) { $ filter = array_filter ( $ this -> privilege , function ( $ row ) use ( $ id ) { return $ row [ 'id' ] == $ id ; } ) ; return ( array ) array_pop ( $ filter ) ; } return ( array ) ( $ this -> privilege [ $ id ] ?? ... | Get privilege . |
53,908 | public function getIdPrivilegeByName ( string $ name ) : string { if ( isset ( $ this -> privilege [ $ name ] ) ) { return ( string ) $ this -> privilege [ $ name ] [ 'id' ] ; } return '' ; } | Get id privilege by name . |
53,909 | public function getAcl ( string $ idRole = null , string $ idResource = null ) : array { if ( $ idRole ) { $ callback = function ( $ row ) use ( $ idRole , $ idResource ) { if ( $ idRole && $ idResource ) { return $ row [ 'id_role' ] == $ idRole && $ row [ 'id_resource' ] == $ idResource ; } if ( $ idRole ) { return $ ... | Get acl . |
53,910 | public function getAclForm ( string $ idRole ) : array { $ result = [ ] ; foreach ( $ this -> resource as $ item ) { $ acl = $ this -> getAcl ( $ idRole , ( string ) $ item [ 'id' ] ) ; if ( $ this -> isAll ( $ idRole , ( string ) $ item [ 'id' ] ) ) { $ result [ $ item [ 'id' ] ] = 'all' ; } else { $ result [ $ item [... | Get acl form . |
53,911 | public function isAll ( string $ idRole , string $ idResource = null ) : bool { $ acl = $ this -> getAcl ( $ idRole ) ; if ( $ idResource ) { $ callback = function ( $ row ) use ( $ idResource ) { if ( $ idResource ) { return $ row [ 'id_resource' ] == $ idResource ; } return true ; } ; $ res = array_values ( array_fil... | Is all . |
53,912 | public function setAllowed ( $ role = self :: ALL , $ resource = self :: ALL , $ privilege = self :: ALL ) { if ( $ this -> policy == self :: POLICY_ALLOW ) { $ this -> permission -> allow ( $ role , $ resource , $ privilege ) ; } else { $ this -> permission -> deny ( $ role , $ resource , $ privilege ) ; } } | Set allowed . |
53,913 | private function getPathListCurrentAcl ( ) : string { return sprintf ( self :: PATH_LIST_CURRENT_ACL , $ this -> appDir , explode ( '\\' , get_class ( $ this ) ) [ 3 ] ) ; } | Get path list current acl . |
53,914 | public function saveListCurrentAcl ( ) : int { $ separate = $ last = $ this -> loadListCurrentAcl ( ) ; foreach ( $ this -> listCurrentAcl as $ item ) { if ( ! isset ( $ separate [ $ item [ 'resource' ] ] ) ) { $ separate [ $ item [ 'resource' ] ] = [ ] ; } if ( ! in_array ( $ item [ 'privilege' ] , $ separate [ $ item... | Save list current acl . |
53,915 | public function loadListCurrentAcl ( ) : array { $ path = $ this -> getPathListCurrentAcl ( ) ; if ( file_exists ( $ path ) ) { return Neon :: decode ( file_get_contents ( $ path ) ) ; } return [ ] ; } | Load list current acl . |
53,916 | public static function merge ( $ array1 , $ array2 , $ recursive = false ) { if ( ! self :: isValid ( $ array1 ) || ! self :: isValid ( $ array2 ) ) { return false ; } if ( $ recursive ) { return array_merge_recursive ( $ array1 , $ array2 ) ; } else { return array_merge ( $ array1 , $ array2 ) ; } } | Merge 2 arrays |
53,917 | public static function existsValue ( $ array , $ value ) { if ( ! self :: isValid ( $ array ) ) { return false ; } $ returnValue = false ; $ length = self :: length ( $ array ) ; for ( $ i = 0 ; $ i < $ length ; $ i ++ ) { if ( $ value === $ array [ $ i ] ) { $ returnValue = true ; break ; } } return $ returnValue ; } | Check if a value exists in an array |
53,918 | public static function explode ( $ string , $ delimiter ) { if ( ! String :: isValid ( $ string ) || String :: isEmpty ( $ string ) ) { return false ; } return explode ( $ delimiter , $ string ) ; } | Convert a string to an array |
53,919 | public static function getLogger ( ) { if ( self :: $ logger === null ) { try { $ result = Hook :: execute ( "Wedeto.Util.GetLogger" , [ "logger" => null , "class" => static :: class ] ) ; } catch ( RecursionException $ e ) { $ result = [ 'logger' => new EmergencyLogger ] ; } self :: $ logger = $ result [ 'logger' ] ??... | Get a logger . If not available yet it will be created using a Hook or a NullLogger is instantiated . |
53,920 | public function addValue ( $ value , $ q = 1.0 ) { $ val = $ this -> parseValue ( $ value ) ; $ q = floatval ( $ q ) ; if ( $ q > 1 ) { $ q = 1.0 ; } if ( $ q < 0 ) { $ q = 0.0 ; } foreach ( $ this -> values as $ index => $ tmp ) { if ( $ tmp [ self :: KEY_VAL ] == $ val ) { array_splice ( $ this -> values , $ index , ... | Add a value to the header uses a modified version of insertion sort . |
53,921 | protected function getConfig ( ServiceLocatorInterface $ serviceLocator ) { if ( $ this -> config !== null ) { return $ this -> config ; } $ services = $ serviceLocator -> getServiceLocator ( ) ; if ( ! $ services -> has ( 'Config' ) ) { $ this -> config = array ( ) ; return $ this -> config ; } $ config = $ services -... | Get amqp configuration if any |
53,922 | public function setAI ( $ arg ) { $ this -> aiBegin = max ( $ this -> aiBegin , intval ( $ arg ) ) ; return $ this ; } | SET AUTO_INCREMENT BEGIN |
53,923 | public function fk ( $ name , $ field , $ table , $ fkField , $ delete = 'NO ACTION' , $ update = 'NO ACTION' ) { $ this -> foreignKey [ $ name ] = [ $ field , $ table , $ fkField , $ delete , $ update ] ; return $ this ; } | SET FOREIGN KEY |
53,924 | public function getAlertSql ( ) { $ sql = [ ] ; foreach ( $ this -> _data as $ item ) { $ sql [ ] = $ item -> getAlterSql ( ) ; } return sprintf ( 'ALTER TABLE %s %s;' , $ this -> getTable ( ) , implode ( ',' , $ sql ) ) ; } | GET ALERT TABLE SQL |
53,925 | public function getSql ( ) { $ sql = "CREATE TABLE IF NOT EXISTS {$this->getTable()} (" ; $ column = $ this -> _data ; if ( ! empty ( $ this -> primaryKey ) ) { $ column [ ] = "PRIMARY KEY (`{$this->primaryKey}`)" ; } foreach ( $ this -> checks as $ key => $ item ) { $ column [ ] = ( ! is_integer ( $ key ) ? "CONSTRAIN... | GET CREATE TABLE SQL |
53,926 | public function getForeignKey ( ) { if ( $ this -> foreignKey !== null ) { return $ this -> foreignKey ; } $ this -> init ( ) ; switch ( $ this -> type ) { case self :: HAS_MANY : case self :: HAS_ONE : return $ this -> owner -> getTableName ( ) . '_' . $ this -> owner -> getPrimaryKey ( ) ; case self :: BELONGS_TO : r... | Returns the name of the column that will be filtered on |
53,927 | public static function create ( $ format = self :: FORMAT_JSON , $ engine = self :: ENGINE_API ) { $ response = '\Eureka\Component\Response' ; switch ( $ format ) { case self :: FORMAT_JSON : $ responseFormat = '\Json' ; break ; case self :: FORMAT_HTML : $ responseFormat = '\Html' ; break ; case self :: FORMAT_XML : c... | Create response object . |
53,928 | private function filterPath ( $ path ) { if ( $ path != null && substr ( $ path , 0 , 1 ) !== '/' ) { $ path = '/' . $ path ; } return preg_replace_callback ( '/(?:[^' . self :: $ charUnreserved . ':@&=\+\$,\/;%]+|%(?![A-Fa-f0-9]{2}))/' , function ( $ match ) { return rawurlencode ( $ match [ 0 ] ) ; } , $ path ) ; } | Filters the path of a URI |
53,929 | function reset ( ) { foreach ( $ this -> vars as $ key => $ val ) { unset ( $ this -> env [ $ key ] ) ; } $ this -> vars = array ( ) ; } | Resets evaluator s variables |
53,930 | public function map ( $ prefix , $ paths ) { $ prefix = ltrim ( $ prefix , '\\' ) ; $ paths = ( array ) $ paths ; if ( ! isset ( $ this -> map [ $ prefix ] ) ) { $ this -> map [ $ prefix ] = array ( ) ; } foreach ( $ paths as $ path ) { $ this -> map [ $ prefix ] [ ] = rtrim ( $ path , '\\/' ) . DIRECTORY_SEPARATOR ; }... | Maps a namespace prefix to one or more base directory paths . |
53,931 | protected function getPath ( $ class ) { foreach ( $ this -> map as $ prefix => $ paths ) { if ( 0 !== strpos ( $ class , $ prefix ) ) { continue ; } foreach ( $ paths as $ path ) { $ relative = ltrim ( substr ( $ class , strlen ( $ prefix ) ) , '\\' ) ; $ relative = preg_replace ( '/\\\\+/' , DIRECTORY_SEPARATOR , $ r... | Returns the file path for the class name . |
53,932 | public function passes ( $ input , $ rules ) { foreach ( $ rules as $ field => $ rule ) { $ this -> callValidator ( $ input [ $ field ] , $ field , $ rule ) ; } return ! $ this -> failed ; } | Loops through the rules and checks the current input . |
53,933 | protected function unique ( $ input , $ table , $ column ) { $ email = $ this -> db -> get ( $ table , $ column , [ $ column => $ input ] ) ; if ( $ email ) { var_dump ( "error: {$column} not unique" ) ; $ this -> failed = true ; } } | Check if the given input is unique in the given database table and column . |
53,934 | protected function multiple ( $ value ) { $ arguments = explode ( ':' , $ value ) ; if ( count ( $ arguments ) > 1 ) { $ rule = $ arguments [ 0 ] ; unset ( $ arguments [ 0 ] ) ; return [ 'multiple' => true , 'rule' => $ rule , 'arguments' => array_values ( $ arguments ) ] ; } return [ 'multiple' => false ] ; } | Retrieves multiple arguments from argument string . |
53,935 | protected function callValidator ( $ input , $ field , $ arguments ) { $ arguments = explode ( '|' , $ arguments ) ; foreach ( $ arguments as $ arg ) { if ( $ this -> multiple ( $ arg ) [ 'multiple' ] ) { switch ( $ this -> multiple ( $ arg ) [ 'rule' ] ) { case 'unique' : $ table = $ this -> multiple ( $ arg ) [ 'argu... | Loops through all arguments and checks what methods need to be called . |
53,936 | protected function table ( $ table ) { return $ this -> db -> connection ( $ this -> connection ) -> table ( $ table ) -> useWritePdo ( ) ; } | Get a query builder for the given table . |
53,937 | protected function normalizeTranslations ( Model \ TranslatableInterface $ translatable , $ format , array $ context = [ ] ) { $ data = [ ] ; $ groups = isset ( $ context [ 'groups' ] ) ? ( array ) $ context [ 'groups' ] : [ ] ; if ( in_array ( 'Search' , $ groups ) ) { if ( $ translatable instanceof Model \ Translatab... | Normalizes the translatable s translations . |
53,938 | private function Groups ( ) { if ( $ this -> groups === null ) { $ this -> groups = array ( ) ; if ( $ this -> GetMember ( ) ) { $ this -> groups = MembergroupUtil :: MemberMembergroups ( $ this -> GetMember ( ) ) ; } } return $ this -> groups ; } | The groups of the current member |
53,939 | public function Grant ( Action $ action , $ onObject ) { if ( $ onObject instanceof Page ) { return $ this -> GrantOnPage ( $ onObject ) ; } if ( $ onObject instanceof Content ) { return $ this -> GrantOnContent ( $ onObject , $ action ) ; } else { throw new \ LogicException ( 'Frontend access check not implemented for... | Check access to an object in the frontend |
53,940 | private function GrantByProperties ( $ guestsOnly , $ publish , Date $ from = null , Date $ to = null , array $ groups = array ( ) ) { if ( ! PublishDateUtil :: IsPublishedNow ( $ publish , $ from , $ to ) ) { return GrantResult :: NoAccess ( ) ; } if ( $ this -> GetMember ( ) && $ guestsOnly ) { return GrantResult :: ... | Checks access to an item by its properties and assigned groups |
53,941 | private function GrantOnPage ( Page $ page ) { $ groups = MembergroupUtil :: PageMembergroups ( $ page ) ; return $ this -> GrantByProperties ( $ page -> GetGuestsOnly ( ) , $ page -> GetPublish ( ) , $ page -> GetPublishFrom ( ) , $ page -> GetPublishTo ( ) , $ groups ) ; } | Checks a page for access rights |
53,942 | private function GrantOnContent ( Content $ content ) { $ groups = MembergroupUtil :: ContentMembergroups ( $ content ) ; return $ this -> GrantByProperties ( $ content -> GetGuestsOnly ( ) , $ content -> GetPublish ( ) , $ content -> GetPublishFrom ( ) , $ content -> GetPublishTo ( ) , $ groups ) ; } | Checks access to a content |
53,943 | public function run ( ) { $ url = parse_url ( $ _SERVER [ 'REQUEST_URI' ] ) ; $ controller = $ this -> router -> find ( $ url [ 'path' ] ) ; if ( ! $ controller instanceof ControllerInterface ) { throw new \ RuntimeException ( 'No valid controller found.' ) ; } $ controller -> setServer ( $ this ) ; $ result = $ contro... | Runs the listener . |
53,944 | public function channelGroupList ( array $ filter = array ( ) ) { if ( $ this -> cgroupList === null ) { $ this -> cgroupList = $ this -> request ( "channelgrouplist" ) -> toAssocArray ( "cgid" ) ; foreach ( $ this -> cgroupList as $ cgid => $ group ) { $ this -> cgroupList [ $ cgid ] = new Channelgroug ( $ this , $ gr... | Returns a list of channel groups available . |
53,945 | public static function delete ( ) { foreach ( func_get_args ( ) as $ argument ) { if ( is_array ( $ argument ) ) { foreach ( $ argument as $ key ) { unset ( $ _SESSION [ ( string ) $ key ] ) ; } } else { unset ( $ _SESSION [ ( string ) $ argument ] ) ; } } } | Deletes one or more session variables . |
53,946 | public static function exists ( ) : bool { if ( ! session_id ( ) ) { Session :: start ( ) ; } foreach ( func_get_args ( ) as $ argument ) { if ( is_array ( $ argument ) ) { foreach ( $ argument as $ key ) { if ( ! isset ( $ _SESSION [ ( string ) $ key ] ) ) { return false ; } } } else { if ( ! isset ( $ _SESSION [ ( st... | Checks if a session variable exists . |
53,947 | public static function get ( string $ key ) { if ( ! session_id ( ) ) { self :: start ( ) ; } if ( Session :: exists ( ( string ) $ key ) ) { return $ _SESSION [ ( string ) $ key ] ; } return null ; } | Gets a variable that was stored in the session . |
53,948 | public static function set ( string $ key , $ value ) { if ( ! session_id ( ) ) { self :: start ( ) ; } $ _SESSION [ ( string ) $ key ] = $ value ; } | Stores a variable in the session . |
53,949 | public static function getFormattedIdentifier ( ClassMetadata $ relatedClass , array $ criteria , $ fieldName , $ value ) { $ isObject = \ is_object ( $ criteria [ $ fieldName ] ) ; return $ isObject && null === $ value ? self :: formatEmptyIdentifier ( $ relatedClass ) : $ value ; } | Get the formatted identifier . |
53,950 | public static function formatEmptyIdentifier ( ClassMetadata $ meta ) { $ type = $ meta -> getTypeOfField ( current ( $ meta -> getIdentifier ( ) ) ) ; switch ( $ type ) { case 'bigint' : case 'decimal' : case 'integer' : case 'smallint' : case 'float' : return 0 ; case 'guid' : return '00000000-0000-0000-0000-00000000... | Format the empty identifier value for entity with relation . |
53,951 | public static function getObjectManager ( ManagerRegistry $ registry , $ entity , Constraint $ constraint ) { self :: validateConstraint ( $ constraint ) ; return self :: findObjectManager ( $ registry , $ entity , $ constraint ) ; } | Pre validate entity . |
53,952 | public static function updateCito ( Event $ event ) { $ options = static :: getOptions ( $ event ) ; $ configDir = $ options [ 'symfony-config-dir' ] ; $ templateDir = $ options [ 'symfony-template-dir' ] ; $ fs = new Filesystem ( ) ; $ yaml = Yaml :: parseFile ( $ configDir . '/packages/cito.yaml' ) ; if ( ! array_key... | Update the Cito files without delete user changes |
53,953 | public function sameValueAs ( ValueObjectInterface $ timezone ) { if ( false === Util :: classEquals ( $ this , $ timezone ) ) { return false ; } return $ this -> getName ( ) -> sameValueAs ( $ timezone -> getName ( ) ) ; } | Tells whether two DateTimeZone are equal by comparing their names |
53,954 | public function setQuery ( $ query ) { $ raw = SqlFormatter :: removeComments ( $ query ) ; if ( $ this -> noSplit ) { $ queries = array ( $ raw ) ; } else { $ queries = SqlFormatter :: splitQuery ( $ raw ) ; } foreach ( $ queries as $ index => $ q ) { $ this -> addOrReplace ( $ index , $ q ) ; } $ this -> removeFromIn... | Set SQL Query . |
53,955 | public function setResultDataType ( $ resultDataType ) { if ( is_string ( $ resultDataType ) && class_exists ( $ resultDataType ) ) { $ resultDataType = new $ resultDataType ( ) ; } if ( $ resultDataType instanceof DataInterface ) { $ this -> resultDataType = $ resultDataType ; } $ objectType = is_object ( $ resultData... | Set Result Data Type . |
53,956 | public function setInitializer ( QueryInitializer $ initial ) { $ this -> initial = $ initial ; for ( $ i = 0 ; $ i < $ this -> length ( ) ; ++ $ i ) { if ( $ this -> offsetExists ( $ i ) ) { $ this -> offsetGet ( $ i ) -> setInitializer ( $ this -> initial ) ; } } } | Set Initializer Class . |
53,957 | public function add ( SQLInterface $ sql ) { $ this -> raw [ ] = $ sql -> toString ( ) ; if ( ! $ sql -> getId ( ) ) { $ sql -> setId ( $ this -> count ( ) + 1 ) ; } $ sql -> setInitializer ( $ this -> initial ) ; $ this -> append ( $ sql ) ; } | Append SQL Object . |
53,958 | public function toArray ( ) { $ arrayResult = array ( ) ; for ( $ i = 0 ; $ i < $ this -> length ( ) ; ++ $ i ) { if ( $ this -> offsetExists ( $ i ) ) { $ arrayResult [ ] = $ this -> offsetGet ( $ i ) -> toArray ( ) ; } } return $ arrayResult ; } | Get All SQL Query as an array . |
53,959 | public function clear ( ) { for ( $ i = 0 ; $ i < $ this -> length ( ) ; ++ $ i ) { if ( $ this -> offsetExists ( $ i ) ) { $ this -> offsetUnset ( $ i ) ; } } } | Clear all sql queries . |
53,960 | public function last ( ) { $ lastIndex = $ this -> count ( ) - 1 ; if ( $ this -> offsetExists ( $ lastIndex ) ) { return $ this -> offsetGet ( $ lastIndex ) ; } } | Get last sql query if single query will return first query . |
53,961 | public function addOrReplace ( $ index , $ stringSql ) { if ( ! $ stringSql ) { return ; } $ sql = null ; if ( $ this -> offsetExists ( $ index ) ) { $ sql = $ this -> offsetGet ( $ index ) ; $ sql -> setSql ( $ stringSql ) ; } else { $ sql = new Sql ( $ stringSql ) ; $ this -> add ( $ sql ) ; } return $ sql ; } | Add Or Replace old query . |
53,962 | public function regenerate ( ) { $ pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' ; $ sessionId = '' ; for ( $ i = 0 ; $ i < 32 ; $ i ++ ) { $ sessionId .= substr ( $ pool , mt_rand ( 0 , strlen ( $ pool ) - 1 ) , 1 ) ; } $ this -> setSessionId ( $ sessionId ) ; } | Regenerates the session id |
53,963 | public function setInstances ( Manager $ manager , DataContainer $ data , FlashContainer $ flash ) { $ this -> manager = $ manager ; $ this -> data = $ data ; $ this -> flash = $ flash ; } | Sets the manager that manages this driver and container instances for this session |
53,964 | protected function findSessionId ( ) { if ( ! empty ( $ this -> config [ 'post_cookie_name' ] ) and isset ( $ _POST [ $ this -> config [ 'post_cookie_name' ] ] ) ) { $ this -> sessionId = $ _POST [ $ this -> config [ 'post_cookie_name' ] ] ; } elseif ( ! empty ( $ this -> config [ 'enable_cookie' ] ) and isset ( $ _COO... | Finds the current session id |
53,965 | protected function setCookie ( $ name , $ value ) { $ expiration = $ this -> expiration > 0 ? $ this -> expiration + time ( ) : 0 ; return setcookie ( $ name , $ value , $ expiration , $ this -> config [ 'cookie_path' ] , $ this -> config [ 'cookie_domain' ] , $ this -> config [ 'cookie_secure' ] , $ this -> config [ '... | Sets a cookie . Note that all cookie values must be strings and no automatic serialization will be performed! |
53,966 | protected function deleteCookie ( $ name ) { unset ( $ _COOKIE [ $ name ] ) ; return setcookie ( $ name , null , - 86400 , $ this -> config [ 'cookie_path' ] , $ this -> config [ 'cookie_domain' ] , $ this -> config [ 'cookie_secure' ] , $ this -> config [ 'cookie_http_only' ] ) ; } | Deletes a cookie by making the value null and expiring it |
53,967 | protected function createFields ( $ pclass ) { $ fields = array ( ) ; $ fields [ ] = $ this -> dom -> createElement ( 'description' ) ; end ( $ fields ) -> appendChild ( $ this -> dom -> createTextNode ( $ pclass -> getDescription ( ) ) ) ; $ fields [ ] = $ this -> dom -> createElement ( 'months' , $ pclass -> getMonth... | Creates DOMElement for all fields for specified PClass . |
53,968 | public function watermark ( ImageResource $ watermark , $ watermarkPos = 4 , $ watermarkMargin = 10 ) { switch ( $ watermarkPos ) { case 0 : $ watermarkdestX = $ this -> width / 2 - $ watermark -> getWidth ( ) / 2 ; $ watermarkdestY = $ this -> height / 2 - $ watermark -> getHeight ( ) / 2 ; break ; case 1 : $ watermar... | adds a watermark to the image |
53,969 | public function trnRegister ( $ redirect = false ) { $ crc = md5 ( $ this -> postData [ "p24_session_id" ] . "|" . $ this -> posId . "|" . $ this -> postData [ "p24_amount" ] . "|" . $ this -> postData [ "p24_currency" ] . "|" . $ this -> salt ) ; $ this -> addValue ( "p24_sign" , $ crc ) ; $ RES = $ this -> callUrl ( ... | Prepare a transaction request |
53,970 | public function trnRequest ( $ token , $ redirect = true ) { if ( $ redirect ) { header ( "Location:" . $ this -> hostLive . "trnRequest/" . $ token ) ; return "" ; } else { return $ this -> hostLive . "trnRequest/" . $ token ; } } | Redirects or returns URL to a P24 payment screen |
53,971 | public function apply ( Builder $ builder , Model $ model ) : void { $ builder -> orderBy ( self :: NAME_ATTRIBUTE ) ; } | Apply the sort by name scope to a given Eloquent query builder . |
53,972 | public function setValue ( $ key , $ value ) { $ this -> startSession ( ) ; $ _SESSION [ $ key ] = $ value ; $ this -> sessionData = null ; session_write_close ( ) ; } | Set a session value by key and invalidate the session data |
53,973 | public function getValue ( $ key , $ lockSession = false ) { $ allValues = $ this -> getAllValues ( $ lockSession ) ; if ( isset ( $ allValues [ $ key ] ) ) { return $ allValues [ $ key ] ; } else { return null ; } } | Get a session value by key |
53,974 | public function getAllValues ( $ lockSession = false ) { if ( ! $ this -> sessionData || $ lockSession ) { $ this -> startSession ( ) ; $ this -> sessionData = isset ( $ _SESSION ) ? $ _SESSION : array ( ) ; if ( ! $ lockSession ) session_write_close ( ) ; } return $ this -> sessionData ; } | Get all values - return as array and close session to prevent threading locks . |
53,975 | public function assertFieldSetName ( string ... $ name ) { if ( ! \ in_array ( $ providedName = $ this -> fieldSet -> getSetName ( ) , $ name , true ) ) { throw new UnsupportedFieldSetException ( $ name , $ providedName ) ; } } | Checks that the FieldSet of this condition is supported by the contexts it s used in . |
53,976 | final public function create ( $ type , array $ args = null , callable $ cb = null ) { if ( ! is_string ( $ type ) ) { throw new InvalidArgumentException ( sprintf ( '%s: Type must be a string.' , get_called_class ( ) ) ) ; } if ( ! isset ( $ args ) ) { $ args = $ this -> arguments ( ) ; } $ pool = get_called_class ( )... | Create a new instance of a class by type . |
53,977 | public function setBaseClass ( $ type ) { if ( ! is_string ( $ type ) || empty ( $ type ) ) { throw new InvalidArgumentException ( 'Class name or type must be a non-empty string.' ) ; } $ exists = ( class_exists ( $ type ) || interface_exists ( $ type ) ) ; if ( $ exists ) { $ className = $ type ; } else { $ className ... | If a base class is set then it must be ensured that the created objects are instanceof this base class . |
53,978 | public function resolve ( $ type ) { if ( ! is_string ( $ type ) ) { throw new InvalidArgumentException ( 'Can not resolve class ident: type must be a string' ) ; } $ map = $ this -> map ( ) ; if ( isset ( $ map [ $ type ] ) ) { $ type = $ map [ $ type ] ; } if ( class_exists ( $ type ) ) { return $ type ; } $ resolver... | The Generic factory resolves the class name from an exact FQN . |
53,979 | public function isResolvable ( $ type ) { if ( ! is_string ( $ type ) ) { throw new InvalidArgumentException ( 'Can not check resolvable: type must be a string' ) ; } $ map = $ this -> map ( ) ; if ( isset ( $ map [ $ type ] ) ) { $ type = $ map [ $ type ] ; } if ( class_exists ( $ type ) ) { return true ; } $ resolver... | Whether a type is resolvable . The Generic Factory simply checks if the _FQN_ type class exists . |
53,980 | protected function createClass ( $ className , $ args ) { if ( $ args === null ) { return new $ className ; } if ( ! is_array ( $ args ) ) { return new $ className ( $ args ) ; } if ( count ( array_filter ( array_keys ( $ args ) , 'is_string' ) ) > 0 ) { return new $ className ( $ args ) ; } else { $ reflection = new R... | Create a class instance with given arguments . |
53,981 | protected function addClassToMap ( $ type , $ className ) { if ( ! is_string ( $ type ) ) { throw new InvalidArgumentException ( 'Type (class key) must be a string' ) ; } $ this -> map [ $ type ] = $ className ; return $ this ; } | Add a class name to the available types _map_ . |
53,982 | private function setMap ( array $ map ) { $ this -> map = [ ] ; foreach ( $ map as $ type => $ className ) { $ this -> addClassToMap ( $ type , $ className ) ; } return $ this ; } | Add multiple types in a an array of type = > className . |
53,983 | public function validate ( $ value ) { return is_array ( $ value ) ? $ this -> valueSchema -> validate ( $ value ) : Error :: unit ( [ Error :: NON_ARRAY ] ) ; } | Tells if a given value adhere s to the property s value schema . |
53,984 | protected function createValueSchema ( array $ definition ) { if ( ! isset ( $ definition [ 'properties' ] ) ) { throw new Exception ( "Missing required key 'properties' within assoc definition." ) ; } return $ this -> getSchema ( ) -> getFactory ( ) -> createSchema ( $ this -> getName ( ) . '_type' , [ 'type' => 'asso... | Creates a schema instance that will be used to proxy the property s validation to . |
53,985 | public function toArray ( ) : array { $ array = [ 'id' => $ this -> getId ( ) , ] ; foreach ( get_object_vars ( $ this ) as $ prop => $ value ) { $ array [ $ prop ] = is_callable ( [ $ this -> $ prop , 'toArray' ] ) ? $ this -> $ prop -> toArray ( ) : $ this -> $ prop ; } return $ array ; } | Convert Interoperable Model to an array |
53,986 | public function findCacheByString ( string $ string ) { if ( ! $ this -> isCachedByString ( $ string ) ) { return null ; } return $ this -> cacheByString [ $ string ] ; } | Find an existing cache by string |
53,987 | public static function real ( $ input , $ separator = self :: SEPARATOR_BOTH ) { $ parsed = self :: parse ( $ input , $ separator ) ; if ( ! self :: validate ( $ parsed [ "path" ] ) ) throw new \ Exception ( "Path is invalid" ) ; $ elements_in = self :: explode ( $ parsed [ "path" ] , $ separator ) ; $ elements_out = a... | Resolve a path and return a cleaned real path without checking physical files on any device |
53,988 | public static function validate ( $ input , $ separator = self :: SEPARATOR_BOTH ) { $ pattern = addcslashes ( self :: ALLOWED_CHARS . $ separator , "[].-_/\\" ) ; $ invalid = preg_match ( "/[^" . $ pattern . "]+/" , $ input ) ; return $ invalid ? false : true ; } | Check if a path contains valid characters |
53,989 | public static function extension ( $ file , $ separator = self :: SEPARATOR_BOTH ) { return self :: validate ( $ file , $ separator ) ? substr ( $ file , strrpos ( $ file , '.' ) + 1 ) : false ; } | Return the extension of a file or false on invalid filenames |
53,990 | public static function createFromMutable ( \ ArrayObject $ arrayObject ) : ImmutableArrayObject { return new static ( $ arrayObject -> getArrayCopy ( ) , $ arrayObject -> getFlags ( ) , $ arrayObject -> getIteratorClass ( ) ) ; } | Creates a new ImmutableArrayObject from the given mutable ArrayObject instance . |
53,991 | public function connect ( $ host = '127.0.0.1' , $ port = 11211 ) { if ( ! isset ( $ this -> servers [ $ host . ':' . $ port ] ) ) { $ this -> server = new \ Memcache ( ) ; $ this -> server -> connect ( $ host , $ port ) ; $ this -> servers [ $ host . ':' . $ port ] = $ this -> server ; } else { $ this -> server = $ th... | Connect and use specified server . |
53,992 | public function addUser ( $ name , $ userName , $ email , $ password ) { $ model = $ this -> getUserDefinition ( ) -> modelInstance ( ) ; $ model -> setName ( $ name ) ; $ model -> setEmail ( $ email ) ; $ model -> setUsername ( $ userName ) ; $ model -> setPassword ( $ password ) ; $ this -> save ( $ model ) ; } | Add new user in database |
53,993 | public function getByEmail ( $ email ) { $ filter = new IteratorFilter ( ) ; $ filter -> addRelation ( $ this -> getUserDefinition ( ) -> getEmail ( ) , Relation :: EQUAL , strtolower ( $ email ) ) ; return $ this -> getUser ( $ filter ) ; } | Get the user based on his email . Return Row if user was found ; null otherwise |
53,994 | public function getByUsername ( $ username ) { $ filter = new IteratorFilter ( ) ; $ filter -> addRelation ( $ this -> getUserDefinition ( ) -> getUsername ( ) , Relation :: EQUAL , $ username ) ; return $ this -> getUser ( $ filter ) ; } | Get the user based on his username . Return Row if user was found ; null otherwise |
53,995 | public function getById ( $ userid ) { $ filter = new IteratorFilter ( ) ; $ filter -> addRelation ( $ this -> getUserDefinition ( ) -> getUserid ( ) , Relation :: EQUAL , $ userid ) ; return $ this -> getUser ( $ filter ) ; } | Get the user based on his id . Return Row if user was found ; null otherwise |
53,996 | public function isValidUser ( $ userName , $ password ) { $ filter = new IteratorFilter ( ) ; $ passwordGenerator = $ this -> getUserDefinition ( ) -> getClosureForUpdate ( 'password' ) ; $ filter -> addRelation ( $ this -> getUserDefinition ( ) -> loginField ( ) , Relation :: EQUAL , strtolower ( $ userName ) ) ; $ fi... | Validate if the user and password exists in the file Return Row if user exists ; null otherwise |
53,997 | public function hasProperty ( $ userId , $ propertyName , $ value = null ) { $ user = $ this -> getById ( $ userId ) ; if ( empty ( $ user ) ) { return false ; } if ( $ this -> isAdmin ( $ userId ) ) { return true ; } $ values = $ user -> get ( $ propertyName ) ; return ( $ values !== null ? in_array ( $ value , ( arra... | Check if the user have a property and it have a specific value . Return True if have rights ; false otherwise |
53,998 | public function getProperty ( $ userId , $ propertyName ) { $ user = $ this -> getById ( $ userId ) ; if ( $ user !== null ) { $ values = $ user -> get ( $ propertyName ) ; if ( $ this -> isAdmin ( $ userId ) ) { return array ( "admin" => "admin" ) ; } return $ values ; } return null ; } | Return all sites from a specific user Return String vector with all sites |
53,999 | public function createAuthToken ( $ login , $ password , $ jwtWrapper , $ expires = 1200 , $ updateUserInfo = [ ] , $ updateTokenInfo = [ ] ) { if ( ! isset ( $ login ) || ! isset ( $ password ) ) { throw new InvalidArgumentException ( 'Neither username or password can be empty!' ) ; } $ user = $ this -> isValidUser ( ... | Authenticate a user and create a token if it is valid |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.