idx int64 0 60.3k | question stringlengths 101 6.21k | target stringlengths 7 803 |
|---|---|---|
46,800 | public function makeDirectory ( $ mode = NULL ) { $ mode = $ mode ? $ mode : 0777 ; if ( file_exists ( $ this -> path ) ) { if ( is_file ( $ this -> path ) ) { throw new MakeDirectoryException ( $ this ) ; } return ; } $ parent_dir = $ this -> getParent ( ) ; if ( ! $ parent_dir -> exists ( ) ) { $ parent_dir -> makeDirectory ( $ mode ) ; } $ res = @ mkdir ( $ this -> path , $ mode ) ; if ( $ res === FALSE ) { throw new MakeDirectoryException ( $ this ) ; } } | Create empty directory |
46,801 | public function listFiles ( $ filter = NULL ) : array { $ path = $ this -> path ; if ( ! file_exists ( $ path ) ) return NULL ; if ( ! is_readable ( $ path ) ) return NULL ; if ( is_file ( $ path ) ) return NULL ; $ files = array ( ) ; $ dh = opendir ( $ path ) ; while ( ( $ file_name = readdir ( $ dh ) ) !== FALSE ) { if ( $ file_name === '.' || $ file_name === '..' ) { continue ; } $ file = new File ( $ file_name , $ this ) ; if ( $ filter ) { if ( $ filter instanceof FileFilterInterface ) { if ( $ filter -> accept ( $ file ) ) { $ files [ ] = $ file ; } } else if ( is_callable ( $ filter ) ) { if ( $ filter ( $ file ) ) { $ files [ ] = $ file ; } } } else { $ files [ ] = $ file ; } } return $ files ; } | Listing up files in directory which this object means |
46,802 | public function touch ( $ time = NULL ) : bool { if ( $ time === NULL ) { return touch ( $ this -> path ) ; } return touch ( $ this -> path , $ time ) ; } | Update last modified date of the file |
46,803 | private function supportsAnyAttribute ( $ attributes ) { foreach ( $ attributes as $ attribute ) { if ( $ this -> supportsAttribute ( $ attribute ) ) { return true ; } } return false ; } | Test if we support any of the attributes . |
46,804 | private function getRouteRoles ( ) { $ router = $ this -> router ; $ cache = $ this -> getConfigCacheFactory ( ) -> cache ( $ this -> options [ 'cache_dir' ] . '/tenside_roles.php' , function ( ConfigCacheInterface $ cache ) use ( $ router ) { $ routes = $ router -> getRouteCollection ( ) ; $ roles = [ ] ; foreach ( $ routes as $ name => $ route ) { if ( $ requiredRole = $ route -> getOption ( 'required_role' ) ) { $ roles [ $ name ] = $ requiredRole ; } } $ cache -> write ( '<?php return ' . var_export ( $ roles , true ) . ';' , $ routes -> getResources ( ) ) ; } ) ; return require_once $ cache -> getPath ( ) ; } | Get the required roles from cache if possible . |
46,805 | public function createNew ( int $ sourceId , string $ collectionName , array $ data ) : array { return $ this -> sendPost ( sprintf ( '/profiles/%s/raw' , $ this -> userName ) , [ ] , [ 'source_id' => $ sourceId , 'collection' => $ collectionName , 'data' => $ data ] ) ; } | Creates a new raw data for the given source . |
46,806 | public function upsertOne ( int $ sourceId , string $ collectionName , array $ data ) : array { return $ this -> sendPut ( sprintf ( '/profiles/%s/raw' , $ this -> userName ) , [ ] , [ 'source_id' => $ sourceId , 'collection' => $ collectionName , 'data' => $ data ] ) ; } | Tries to update a raw data and if it doesnt exists creates a new raw data . |
46,807 | public function get ( $ name , $ throwAway = false ) { $ client = parent :: get ( $ name , $ throwAway ) ; if ( $ client instanceof ApiKeyClientInterface ) { $ client -> setApiKey ( self :: $ apiKey ) ; } return $ client ; } | set the api key for api key clients |
46,808 | public function showAction ( ProductItemFieldData $ productitemfielddata ) { $ editForm = $ this -> createForm ( $ this -> get ( "amulen.shop.form.product.item.field.data" ) , $ productitemfielddata , array ( 'action' => $ this -> generateUrl ( 'admin_productitemfielddata_update' , array ( 'id' => $ productitemfielddata -> getid ( ) ) ) , 'method' => 'PUT' , ) ) ; $ deleteForm = $ this -> createDeleteForm ( $ productitemfielddata -> getId ( ) , 'admin_productitemfielddata_delete' ) ; return array ( 'productitemfielddata' => $ productitemfielddata , 'edit_form' => $ editForm -> createView ( ) , 'delete_form' => $ deleteForm -> createView ( ) , ) ; } | Finds and displays a ProductItemFieldData entity . |
46,809 | public function newAction ( ) { $ productitemfielddata = new ProductItemFieldData ( ) ; $ form = $ this -> createForm ( $ this -> get ( "amulen.shop.form.product.item.field.data" ) , $ productitemfielddata ) ; return array ( 'productitemfielddata' => $ productitemfielddata , 'form' => $ form -> createView ( ) , ) ; } | Displays a form to create a new ProductItemFieldData entity . |
46,810 | public function createAction ( Request $ request ) { $ productitemfielddata = new ProductItemFieldData ( ) ; $ form = $ this -> createForm ( $ this -> get ( "amulen.shop.form.product.item.field.data" ) , $ productitemfielddata ) ; if ( $ form -> handleRequest ( $ request ) -> isValid ( ) ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ em -> persist ( $ productitemfielddata ) ; $ em -> flush ( ) ; return $ this -> redirect ( $ this -> generateUrl ( 'admin_productitemfielddata_show' , array ( 'id' => $ productitemfielddata -> getId ( ) ) ) ) ; } return array ( 'productitemfielddata' => $ productitemfielddata , 'form' => $ form -> createView ( ) , ) ; } | Creates a new ProductItemFieldData entity . |
46,811 | public function updateAction ( ProductItemFieldData $ productitemfielddata , Request $ request ) { $ editForm = $ this -> createForm ( $ this -> get ( "amulen.shop.form.product.item.field.data" ) , $ productitemfielddata , array ( 'action' => $ this -> generateUrl ( 'admin_productitemfielddata_update' , array ( 'id' => $ productitemfielddata -> getid ( ) ) ) , 'method' => 'PUT' , ) ) ; if ( $ editForm -> handleRequest ( $ request ) -> isValid ( ) ) { $ this -> getDoctrine ( ) -> getManager ( ) -> flush ( ) ; return $ this -> redirect ( $ this -> generateUrl ( 'admin_productitemfielddata_show' , array ( 'id' => $ productitemfielddata -> getId ( ) ) ) ) ; } $ deleteForm = $ this -> createDeleteForm ( $ productitemfielddata -> getId ( ) , 'admin_productitemfielddata_delete' ) ; return array ( 'productitemfielddata' => $ productitemfielddata , 'edit_form' => $ editForm -> createView ( ) , 'delete_form' => $ deleteForm -> createView ( ) , ) ; } | Edits an existing ProductItemFieldData entity . |
46,812 | public function route ( ) { $ batch = array ( ) ; foreach ( $ this -> request -> getCalls ( ) as $ call ) { $ batch [ ] = $ this -> dispatch ( $ call ) ; } return $ this -> response -> encode ( $ batch ) ; } | Do the ExtDirect routing processing . |
46,813 | private function dispatch ( $ call ) { $ path = $ call -> getAction ( ) ; $ method = $ call -> getMethod ( ) ; $ matches = preg_split ( '/(?=[A-Z])/' , $ path ) ; $ route = strtolower ( implode ( '/' , $ matches ) ) ; $ route .= "/" . $ method ; $ request = $ this -> app [ 'request' ] ; $ files = $ this -> fixFiles ( $ request -> files -> all ( ) ) ; $ routeRequest = Request :: create ( $ route , 'POST' , $ call -> getData ( ) , $ request -> cookies -> all ( ) , $ files , $ request -> server -> all ( ) ) ; if ( 'form' == $ this -> request -> getCallType ( ) ) { $ result = $ this -> app -> handle ( $ routeRequest , HttpKernelInterface :: SUB_REQUEST ) ; $ response = $ call -> getResponse ( $ result ) ; } else { try { $ result = $ this -> app -> handle ( $ routeRequest , HttpKernelInterface :: SUB_REQUEST ) ; $ response = $ call -> getResponse ( $ result ) ; } catch ( \ Exception $ e ) { $ response = $ call -> getException ( $ e ) ; } } return $ response ; } | Dispatch a remote method call . |
46,814 | public function CheckPermission ( $ Permission , $ FullMatch = TRUE , $ JunctionTable = '' , $ JunctionID = '' ) { if ( is_object ( $ this -> User ) ) { if ( $ this -> User -> Banned || GetValue ( 'Deleted' , $ this -> User ) ) return FALSE ; elseif ( $ this -> User -> Admin ) return TRUE ; } if ( $ JunctionID == 'any' ) $ JunctionID = '' ; $ Permissions = $ this -> GetPermissions ( ) ; if ( $ JunctionTable && ! C ( 'Garden.Permissions.Disabled.' . $ JunctionTable ) ) { if ( is_array ( $ Permission ) ) { foreach ( $ Permission as $ PermissionName ) { if ( $ this -> CheckPermission ( $ PermissionName , FALSE , $ JunctionTable , $ JunctionID ) ) { if ( ! $ FullMatch ) return TRUE ; } else { if ( $ FullMatch ) return FALSE ; } } return TRUE ; } else { if ( $ JunctionID !== '' ) { $ Result = array_key_exists ( $ Permission , $ Permissions ) && is_array ( $ Permissions [ $ Permission ] ) && in_array ( $ JunctionID , $ Permissions [ $ Permission ] ) ; } else { $ Result = array_key_exists ( $ Permission , $ Permissions ) && is_array ( $ Permissions [ $ Permission ] ) && count ( $ Permissions [ $ Permission ] ) ; } return $ Result ; } } else { if ( is_array ( $ Permission ) ) { return ArrayInArray ( $ Permission , $ Permissions , $ FullMatch ) ; } else { return in_array ( $ Permission , $ Permissions ) || array_key_exists ( $ Permission , $ Permissions ) ; } } } | Checks the currently authenticated user s permissions for the specified permission . Returns a boolean value indicating if the action is permitted . |
46,815 | public function End ( $ Authenticator = NULL ) { if ( $ Authenticator == NULL ) $ Authenticator = Gdn :: Authenticator ( ) ; $ Authenticator -> AuthenticateWith ( ) -> DeAuthenticate ( ) ; $ this -> SetCookie ( '-Vv' , NULL , - 3600 ) ; $ this -> UserID = 0 ; $ this -> User = FALSE ; $ this -> _Attributes = array ( ) ; $ this -> _Permissions = array ( ) ; $ this -> _Preferences = array ( ) ; $ this -> _TransientKey = FALSE ; } | End a session |
46,816 | public function HourOffset ( ) { static $ GuestHourOffset ; if ( $ this -> UserID > 0 ) { return $ this -> User -> HourOffset ; } else { if ( ! isset ( $ GuestHourOffset ) ) { $ GuestTimeZone = C ( 'Garden.GuestTimeZone' ) ; if ( $ GuestTimeZone ) { try { $ TimeZone = new DateTimeZone ( $ GuestTimeZone ) ; $ Offset = $ TimeZone -> getOffset ( new DateTime ( 'now' , new DateTimeZone ( 'UTC' ) ) ) ; $ GuestHourOffset = floor ( $ Offset / 3600 ) ; } catch ( Exception $ Ex ) { $ GuestHourOffset = 0 ; LogException ( $ Ex ) ; } } } return $ GuestHourOffset ; } } | Return the timezone hour difference between the user and utc . |
46,817 | public function Start ( $ UserID = FALSE , $ SetIdentity = TRUE , $ Persist = FALSE ) { if ( ! C ( 'Garden.Installed' , FALSE ) ) return ; $ UserModel = Gdn :: Authenticator ( ) -> GetUserModel ( ) ; $ this -> UserID = $ UserID !== FALSE ? $ UserID : Gdn :: Authenticator ( ) -> GetIdentity ( ) ; $ this -> User = FALSE ; if ( $ this -> UserID > 0 ) { $ this -> User = $ UserModel -> GetSession ( $ this -> UserID ) ; if ( $ this -> User ) { if ( $ SetIdentity ) Gdn :: Authenticator ( ) -> SetIdentity ( $ this -> UserID , $ Persist ) ; $ UserModel -> EventArguments [ 'User' ] = & $ this -> User ; $ UserModel -> FireEvent ( 'AfterGetSession' ) ; $ this -> _Permissions = Gdn_Format :: Unserialize ( $ this -> User -> Permissions ) ; $ this -> _Preferences = Gdn_Format :: Unserialize ( $ this -> User -> Preferences ) ; $ this -> _Attributes = Gdn_Format :: Unserialize ( $ this -> User -> Attributes ) ; $ this -> _TransientKey = is_array ( $ this -> _Attributes ) ? ArrayValue ( 'TransientKey' , $ this -> _Attributes ) : FALSE ; if ( $ this -> _TransientKey === FALSE ) $ this -> _TransientKey = $ UserModel -> SetTransientKey ( $ this -> UserID ) ; $ UserModel -> UpdateVisit ( $ this -> UserID ) ; } else { $ this -> UserID = 0 ; $ this -> User = FALSE ; if ( $ SetIdentity ) Gdn :: Authenticator ( ) -> SetIdentity ( NULL ) ; } } else { $ this -> _TransientKey = GetAppCookie ( 'tk' ) ; } if ( $ this -> UserID == 0 ) $ this -> _Permissions = Gdn_Format :: Unserialize ( $ UserModel -> DefinePermissions ( 0 ) ) ; } | Authenticates the user with the provided Authenticator class . |
46,818 | public function TransientKey ( $ NewKey = NULL ) { if ( ! is_null ( $ NewKey ) ) { $ this -> _TransientKey = Gdn :: Authenticator ( ) -> GetUserModel ( ) -> SetTransientKey ( $ this -> UserID , $ NewKey ) ; } return $ this -> _TransientKey ; } | Returns the transient key for the authenticated user . |
46,819 | private function guessIsIntrospectedStateRootOrLeaf ( ) { foreach ( $ this -> introspectedStates as $ introspectedState ) { $ this -> guessIsIntrospectedStateRoot ( $ introspectedState ) ; $ this -> guessIsIntrospectedStateLeaf ( $ introspectedState ) ; } } | Update introspectedState isLeaf|isRoot on the fly |
46,820 | public function update ( User $ user , $ option , $ categoryKey ) { if ( ! empty ( $ option ) ) { return $ user -> hasPermission ( 'options-update-' . $ categoryKey ) ; } return false ; } | Policy for updating options for specified category |
46,821 | public function executePipeline ( $ pipeline , Request $ request , Response $ response = null ) { $ middleman = new \ mindplay \ middleman \ Dispatcher ( $ pipeline , $ this -> resolver ) ; return $ middleman -> dispatch ( $ request ) ; } | Trigger execution of the supplied pipeline through Middleman . |
46,822 | public function automatic_form ( ) { @ header ( 'text/html; charset=UTF-8' ) ; $ rtn = '' ; if ( ! strlen ( $ this -> options [ 'table' ] ) ) { echo $ this -> page_table_list ( ) ; return null ; } $ table_definition = $ this -> get_current_table_definition ( ) ; if ( ! $ table_definition ) { @ header ( "HTTP/1.0 404 Not Found" ) ; $ rtn = $ this -> page_fatal_error ( 'Table NOT Exists.' ) ; echo $ rtn ; return null ; } if ( ! strlen ( $ this -> options [ 'id' ] ) ) { echo $ this -> page_list ( $ this -> options [ 'table' ] ) ; return null ; } elseif ( $ this -> options [ 'id' ] == ':create' ) { echo $ this -> page_edit ( $ this -> options [ 'table' ] ) ; return null ; } else { $ row_data = $ this -> get_current_row_data ( ) ; if ( ! $ row_data && ! ( $ this -> options [ 'action' ] == 'delete' && $ this -> query_options [ 'action' ] == 'done' ) ) { @ header ( "HTTP/1.0 404 Not Found" ) ; $ rtn = $ this -> page_fatal_error ( 'ID NOT Exists.' ) ; echo $ rtn ; return null ; } if ( $ this -> options [ 'action' ] == 'delete' ) { echo $ this -> page_delete ( $ this -> options [ 'table' ] , $ this -> options [ 'id' ] ) ; } elseif ( $ this -> options [ 'action' ] == 'edit' ) { echo $ this -> page_edit ( $ this -> options [ 'table' ] , $ this -> options [ 'id' ] ) ; } else { echo $ this -> page_detail ( $ this -> options [ 'table' ] , $ this -> options [ 'id' ] ) ; } return null ; } $ rtn = $ this -> page_fatal_error ( 'Unknown method' ) ; echo $ rtn ; return null ; } | Execute Automatic form |
46,823 | public function automatic_signup_form ( $ table_name , $ init_cols , $ options = array ( ) ) { @ header ( 'text/html; charset=UTF-8' ) ; $ param_options = $ this -> get_options ( ) ; $ data = $ param_options [ 'post_params' ] ; $ this -> table_definition = $ this -> exdb -> get_table_definition ( $ table_name ) ; $ is_login = $ this -> exdb -> user ( ) -> is_login ( $ table_name ) ; if ( $ is_login ) { echo '<p>Already Logging in.</p>' ; return true ; } $ page_edit = new endpoint_form_signup ( $ this -> exdb , $ this , $ table_name , $ init_cols , $ options ) ; echo $ page_edit -> execute ( ) ; return true ; } | Automatic Signup form |
46,824 | public function auth ( $ table_name , $ inquiries ) { $ options = $ this -> get_options ( ) ; $ data = $ options [ 'post_params' ] ; if ( @ $ this -> query_options [ 'action' ] == 'login' ) { $ result = $ this -> exdb -> user ( ) -> login ( $ table_name , $ inquiries , $ data ) ; } $ is_login = $ this -> exdb -> user ( ) -> is_login ( $ table_name ) ; if ( $ is_login ) { return true ; } $ table_definition = $ this -> exdb -> get_table_definition ( $ table_name ) ; $ rtn = '' ; foreach ( $ inquiries as $ column_name ) { $ column_definition = $ table_definition -> columns -> { $ column_name } ; $ type_info = $ this -> exdb -> form_elements ( ) -> get_type_info ( $ column_definition -> type ) ; $ form_elm = $ this -> render ( $ type_info [ 'templates' ] [ 'preview' ] , array ( 'value' => @ $ list [ 0 ] [ $ column_definition -> name ] , 'name' => @ $ column_definition -> name , 'def' => @ $ column_definition , ) ) ; $ rtn .= $ this -> render ( 'form_elms_unit.html' , array ( 'label' => @ $ column_definition -> label , 'content' => $ form_elm , 'error' => null , ) ) ; } $ rtn = $ this -> render ( 'form_login.html' , array ( 'is_error' => ( @ $ this -> query_options [ 'action' ] == 'login' ) , 'content' => $ rtn , ) ) ; $ rtn = $ this -> wrap_theme ( $ rtn ) ; echo $ rtn ; return false ; } | Execute Automatic Auth form |
46,825 | public function run ( $ commandline , callable $ callback = null , string $ cwd = null , array $ env = null , $ input = null , ? float $ timeout = 60 ) { $ process = new Process ( $ commandline , $ cwd , $ env , $ input , $ timeout ) ; $ helper = new DebugFormatterHelper ( ) ; $ output = $ this -> output ; $ output -> writeln ( $ helper -> start ( spl_object_hash ( $ process ) , 'Executing: ' . $ commandline , 'STARTED' ) ) ; $ process -> run ( function ( $ type , $ buffer ) use ( $ helper , $ output , $ process , $ callback ) { if ( is_callable ( $ callback ) ) { call_user_func ( $ callback , $ type , $ buffer ) ; } $ contents = $ helper -> progress ( spl_object_hash ( $ process ) , $ buffer , Process :: ERR === $ type ) ; $ output -> write ( $ contents ) ; } ) ; return $ process ; } | Creates process and run with predefined DebugFormatterHelper . |
46,826 | public function translate ( $ string , Array $ vars = array ( ) ) { if ( $ this -> translator ) { return $ this -> translator ( $ this -> getString ( $ string ) , $ vars ) ; } return $ this -> compileString ( $ this -> getString ( $ string ) , $ vars ) ; } | Translates the specified string . |
46,827 | public function getString ( $ string ) { if ( isset ( $ this -> strings [ $ string ] ) ) { return $ this -> strings [ $ string ] ; } else { return $ string ; } } | Fetches the translation for the specified string . |
46,828 | public function calculateNumeral ( $ numeral ) { if ( $ this -> enumerator ) { return $ this -> enumerator ( $ numeral ) ; } return ( $ numeral > 1 or $ numeral < - 1 or $ numeral == 0 ) ? 1 : 0 ; } | Determines which replacement to use for plurals . |
46,829 | protected function compileString ( $ string , $ vars ) { $ translation = $ string ; $ count = 0 ; foreach ( $ vars as $ key => $ val ) { $ count ++ ; if ( is_integer ( $ key ) ) { $ key = $ count ; } $ translation = str_replace ( array ( "{{$key}}" , "{{$count}}" ) , $ val , $ translation ) ; } if ( preg_match_all ( "/{plural:(?<value>-{0,1}\d+)(,|, ){(?<replacements>.*?)}}/i" , $ translation , $ matches ) ) { foreach ( $ matches [ 0 ] as $ id => $ match ) { $ replacements = explode ( '|' , $ matches [ 'replacements' ] [ $ id ] ) ; $ value = $ matches [ 'value' ] [ $ id ] ; $ replacement_id = $ this -> calculateNumeral ( $ value ) ; if ( $ replacement_id !== false ) { $ translation = str_replace ( $ match , $ replacements [ $ replacement_id ] , $ translation ) ; } else { $ translation = str_replace ( $ match , end ( $ replacements ) , $ translation ) ; } } } return $ translation ; } | Compiles the translated string with the variables . |
46,830 | public function initObjects ( $ overrideExisting = true ) { if ( null !== $ this -> collObjects && ! $ overrideExisting ) { return ; } $ this -> collObjects = new ObjectCollection ( ) ; $ this -> collObjects -> setModel ( '\gossi\trixionary\model\Object' ) ; } | Initializes the collObjects collection . |
46,831 | public function getObjects ( Criteria $ criteria = null , ConnectionInterface $ con = null ) { $ partial = $ this -> collObjectsPartial && ! $ this -> isNew ( ) ; if ( null === $ this -> collObjects || null !== $ criteria || $ partial ) { if ( $ this -> isNew ( ) && null === $ this -> collObjects ) { $ this -> initObjects ( ) ; } else { $ collObjects = ChildObjectQuery :: create ( null , $ criteria ) -> filterBySport ( $ this ) -> find ( $ con ) ; if ( null !== $ criteria ) { if ( false !== $ this -> collObjectsPartial && count ( $ collObjects ) ) { $ this -> initObjects ( false ) ; foreach ( $ collObjects as $ obj ) { if ( false == $ this -> collObjects -> contains ( $ obj ) ) { $ this -> collObjects -> append ( $ obj ) ; } } $ this -> collObjectsPartial = true ; } return $ collObjects ; } if ( $ partial && $ this -> collObjects ) { foreach ( $ this -> collObjects as $ obj ) { if ( $ obj -> isNew ( ) ) { $ collObjects [ ] = $ obj ; } } } $ this -> collObjects = $ collObjects ; $ this -> collObjectsPartial = false ; } } return $ this -> collObjects ; } | Gets an array of ChildObject objects which contain a foreign key that references this object . |
46,832 | public function countObjects ( Criteria $ criteria = null , $ distinct = false , ConnectionInterface $ con = null ) { $ partial = $ this -> collObjectsPartial && ! $ this -> isNew ( ) ; if ( null === $ this -> collObjects || null !== $ criteria || $ partial ) { if ( $ this -> isNew ( ) && null === $ this -> collObjects ) { return 0 ; } if ( $ partial && ! $ criteria ) { return count ( $ this -> getObjects ( ) ) ; } $ query = ChildObjectQuery :: create ( null , $ criteria ) ; if ( $ distinct ) { $ query -> distinct ( ) ; } return $ query -> filterBySport ( $ this ) -> count ( $ con ) ; } return count ( $ this -> collObjects ) ; } | Returns the number of related Object objects . |
46,833 | public function addObject ( ChildObject $ l ) { if ( $ this -> collObjects === null ) { $ this -> initObjects ( ) ; $ this -> collObjectsPartial = true ; } if ( ! $ this -> collObjects -> contains ( $ l ) ) { $ this -> doAddObject ( $ l ) ; } return $ this ; } | Method called to associate a ChildObject object to this object through the ChildObject foreign key attribute . |
46,834 | public function initPositions ( $ overrideExisting = true ) { if ( null !== $ this -> collPositions && ! $ overrideExisting ) { return ; } $ this -> collPositions = new ObjectCollection ( ) ; $ this -> collPositions -> setModel ( '\gossi\trixionary\model\Position' ) ; } | Initializes the collPositions collection . |
46,835 | public function getPositions ( Criteria $ criteria = null , ConnectionInterface $ con = null ) { $ partial = $ this -> collPositionsPartial && ! $ this -> isNew ( ) ; if ( null === $ this -> collPositions || null !== $ criteria || $ partial ) { if ( $ this -> isNew ( ) && null === $ this -> collPositions ) { $ this -> initPositions ( ) ; } else { $ collPositions = ChildPositionQuery :: create ( null , $ criteria ) -> filterBySport ( $ this ) -> find ( $ con ) ; if ( null !== $ criteria ) { if ( false !== $ this -> collPositionsPartial && count ( $ collPositions ) ) { $ this -> initPositions ( false ) ; foreach ( $ collPositions as $ obj ) { if ( false == $ this -> collPositions -> contains ( $ obj ) ) { $ this -> collPositions -> append ( $ obj ) ; } } $ this -> collPositionsPartial = true ; } return $ collPositions ; } if ( $ partial && $ this -> collPositions ) { foreach ( $ this -> collPositions as $ obj ) { if ( $ obj -> isNew ( ) ) { $ collPositions [ ] = $ obj ; } } } $ this -> collPositions = $ collPositions ; $ this -> collPositionsPartial = false ; } } return $ this -> collPositions ; } | Gets an array of ChildPosition objects which contain a foreign key that references this object . |
46,836 | public function countPositions ( Criteria $ criteria = null , $ distinct = false , ConnectionInterface $ con = null ) { $ partial = $ this -> collPositionsPartial && ! $ this -> isNew ( ) ; if ( null === $ this -> collPositions || null !== $ criteria || $ partial ) { if ( $ this -> isNew ( ) && null === $ this -> collPositions ) { return 0 ; } if ( $ partial && ! $ criteria ) { return count ( $ this -> getPositions ( ) ) ; } $ query = ChildPositionQuery :: create ( null , $ criteria ) ; if ( $ distinct ) { $ query -> distinct ( ) ; } return $ query -> filterBySport ( $ this ) -> count ( $ con ) ; } return count ( $ this -> collPositions ) ; } | Returns the number of related Position objects . |
46,837 | public function addPosition ( ChildPosition $ l ) { if ( $ this -> collPositions === null ) { $ this -> initPositions ( ) ; $ this -> collPositionsPartial = true ; } if ( ! $ this -> collPositions -> contains ( $ l ) ) { $ this -> doAddPosition ( $ l ) ; } return $ this ; } | Method called to associate a ChildPosition object to this object through the ChildPosition foreign key attribute . |
46,838 | public function getSkillsJoinObject ( Criteria $ criteria = null , ConnectionInterface $ con = null , $ joinBehavior = Criteria :: LEFT_JOIN ) { $ query = ChildSkillQuery :: create ( null , $ criteria ) ; $ query -> joinWith ( 'Object' , $ joinBehavior ) ; return $ this -> getSkills ( $ query , $ con ) ; } | If this collection has already been initialized with an identical criteria it returns the collection . Otherwise if this Sport is new it will return an empty collection ; or if this Sport has previously been saved it will retrieve related Skills from storage . |
46,839 | public function initGroups ( $ overrideExisting = true ) { if ( null !== $ this -> collGroups && ! $ overrideExisting ) { return ; } $ this -> collGroups = new ObjectCollection ( ) ; $ this -> collGroups -> setModel ( '\gossi\trixionary\model\Group' ) ; } | Initializes the collGroups collection . |
46,840 | public function getGroups ( Criteria $ criteria = null , ConnectionInterface $ con = null ) { $ partial = $ this -> collGroupsPartial && ! $ this -> isNew ( ) ; if ( null === $ this -> collGroups || null !== $ criteria || $ partial ) { if ( $ this -> isNew ( ) && null === $ this -> collGroups ) { $ this -> initGroups ( ) ; } else { $ collGroups = ChildGroupQuery :: create ( null , $ criteria ) -> filterBySport ( $ this ) -> find ( $ con ) ; if ( null !== $ criteria ) { if ( false !== $ this -> collGroupsPartial && count ( $ collGroups ) ) { $ this -> initGroups ( false ) ; foreach ( $ collGroups as $ obj ) { if ( false == $ this -> collGroups -> contains ( $ obj ) ) { $ this -> collGroups -> append ( $ obj ) ; } } $ this -> collGroupsPartial = true ; } return $ collGroups ; } if ( $ partial && $ this -> collGroups ) { foreach ( $ this -> collGroups as $ obj ) { if ( $ obj -> isNew ( ) ) { $ collGroups [ ] = $ obj ; } } } $ this -> collGroups = $ collGroups ; $ this -> collGroupsPartial = false ; } } return $ this -> collGroups ; } | Gets an array of ChildGroup objects which contain a foreign key that references this object . |
46,841 | public function addGroup ( ChildGroup $ l ) { if ( $ this -> collGroups === null ) { $ this -> initGroups ( ) ; $ this -> collGroupsPartial = true ; } if ( ! $ this -> collGroups -> contains ( $ l ) ) { $ this -> doAddGroup ( $ l ) ; } return $ this ; } | Method called to associate a ChildGroup object to this object through the ChildGroup foreign key attribute . |
46,842 | public function getAll ( Request $ request ) { $ viewsPath = base_path ( ) . '/resources/views/' ; if ( ! is_dir ( $ viewsPath ) ) { error_log ( "The directory /resources/views/ doesn't exists." ) ; throw new PathNotFoundException ( ) ; } $ langPath = base_path ( ) . '/resources/lang/' ; if ( ! is_dir ( $ langPath ) ) { error_log ( "The directory /resources/lang/ doesn't exists." ) ; throw new PathNotFoundException ( ) ; } $ path = $ request -> input ( 'path' ) ; $ pathInfo = LocaleService :: parsePath ( $ path ) ; LocaleService :: setLang ( $ pathInfo -> lang ) ; $ resp = new \ stdClass ( ) ; $ resp -> langDir = $ pathInfo -> langDir ; $ resp -> pages = null ; $ pagesLastMod = max ( self :: getLastMod ( $ viewsPath ) , self :: getLastMod ( $ langPath ) ) ; $ pagesKey = "pages.{$pathInfo->lang}" ; $ pagesTimestampKey = "pages.{$pathInfo->lang}.timestamp" ; $ cacheEnabled = false ; if ( env ( 'CACHE_DRIVER' ) !== null ) { $ cacheEnabled = true ; } if ( $ cacheEnabled ) { $ pagesLastCache = Cache :: get ( $ pagesTimestampKey ) ; if ( $ pagesLastCache !== null && $ pagesLastCache >= $ pagesLastMod ) { $ resp -> pages = Cache :: get ( $ pagesKey ) ; return response ( ) -> json ( $ resp ) ; } } $ viewsList = self :: getViewsList ( $ viewsPath ) ; LocaleLinkService :: setLang ( $ pathInfo -> lang ) ; LocaleLinkService :: setLangDir ( $ pathInfo -> langDir ) ; $ pages = [ ] ; foreach ( $ viewsList as $ viewName ) { $ page = new \ stdClass ( ) ; $ page -> path = ( $ viewName === 'index' ) ? '' : $ viewName ; $ page -> path = '/' . str_replace ( '.' , '/' , $ page -> path ) ; LocaleLinkService :: setPagePath ( $ page -> path ) ; $ page -> title = view ( $ viewName , [ 'benjamin' => 'benjamin::title' , 'activeLang' => LocaleService :: getActiveLang ( ) , ] ) -> render ( ) ; $ page -> body = view ( $ viewName , [ 'benjamin' => 'benjamin::body' , 'activeLang' => LocaleService :: getActiveLang ( ) , ] ) -> render ( ) ; $ page -> bodyClass = view ( $ viewName , [ 'benjamin' => 'benjamin::bodyClass' , 'activeLang' => LocaleService :: getActiveLang ( ) , ] ) -> render ( ) ; $ pages [ ] = $ page ; } if ( $ cacheEnabled ) { Cache :: forever ( $ pagesKey , $ pages ) ; Cache :: forever ( $ pagesTimestampKey , time ( ) ) ; } $ resp -> pages = $ pages ; return response ( ) -> json ( $ resp ) ; } | Return a JSON object containing the content of all the pages . |
46,843 | private function getLastMod ( $ dirPath ) { $ dirInfo = new \ SplFileInfo ( $ dirPath ) ; $ lastMod = $ dirInfo -> getMTime ( ) ; $ iter = new \ FilesystemIterator ( $ dirPath ) ; foreach ( $ iter as $ fileInfo ) { if ( $ fileInfo -> isDir ( ) ) { $ mtime = self :: getLastMod ( $ fileInfo -> getPathname ( ) ) ; } else { $ mtime = $ fileInfo -> getMTime ( ) ; } if ( $ mtime > $ lastMod ) { $ lastMod = $ mtime ; } } return $ lastMod ; } | Returns the last modification time for all files and directories inside the given directory . |
46,844 | private function getViewsList ( $ dirPath , $ checkSubDir = true ) { $ viewsList = [ ] ; $ iter = new \ FilesystemIterator ( $ dirPath ) ; foreach ( $ iter as $ fileInfo ) { $ filename = $ fileInfo -> getFilename ( ) ; if ( $ filename [ 0 ] === '_' ) { continue ; } if ( $ fileInfo -> isDir ( ) ) { if ( ! $ checkSubDir ) { continue ; } if ( $ filename === 'errors' || $ filename === 'layouts' || $ filename === 'templates' || $ filename === 'vendor' ) { continue ; } $ subViews = self :: getViewsList ( $ fileInfo -> getPathname ( ) ) ; foreach ( $ subViews as $ subViewName ) { $ viewsList [ ] = $ filename . '.' . $ subViewName ; } continue ; } if ( substr ( $ filename , - 10 ) !== '.blade.php' ) { continue ; } $ viewName = substr ( $ filename , 0 , - 10 ) ; $ viewsList [ ] = $ viewName ; } return $ viewsList ; } | Return a list of all available views in the given directory . |
46,845 | private function loadLanguages ( ) { $ app = $ this -> app ; $ engine = $ this ; $ languages = $ app [ 'config.app.languages' ] ; $ app [ 'multi_languages' ] = count ( $ languages ) > 1 ; $ app -> register ( new LocaleServiceProvider ( ) ) ; $ app -> register ( new TranslationServiceProvider ( ) , [ 'locale_fallbacks' => $ languages , ] ) ; $ app [ 'translator.domains' ] = function ( ) use ( $ app , $ engine ) { $ translator_domains = [ 'messages' => [ ] , 'validators' => [ ] , ] ; $ languages = $ app [ 'config.app.languages' ] ; foreach ( $ languages as $ language ) { if ( is_readable ( $ engine -> getAppPath ( 'language' ) . DIRECTORY_SEPARATOR . strtolower ( $ language ) . '.php' ) ) { $ trans = include $ engine -> getAppPath ( 'language' ) . DIRECTORY_SEPARATOR . strtolower ( $ language ) . '.php' ; $ translator_domains [ 'messages' ] [ $ language ] = isset ( $ trans [ 'messages' ] ) ? $ trans [ 'messages' ] : [ ] ; $ translator_domains [ 'validators' ] [ $ language ] = isset ( $ trans [ 'validators' ] ) ? $ trans [ 'validators' ] : [ ] ; } } return $ translator_domains ; } ; } | Load languages . |
46,846 | private function loadRouting ( ) { $ app = $ this -> app ; $ maps = [ ] ; $ routing_file_path = $ this -> getAppPath ( 'config' ) . DIRECTORY_SEPARATOR . 'routing.php' ; if ( is_readable ( $ routing_file_path ) ) { $ maps = require $ routing_file_path ; } if ( $ maps ) { $ prefix_locale = $ app [ 'multi_languages' ] ? '/{_locale}' : '' ; $ app_controller_prefix = $ app [ 'app.vendor_name' ] . '\\Controller\\' ; foreach ( $ maps as $ prefix => $ routes ) { $ map = $ this -> app [ 'controllers_factory' ] ; foreach ( $ routes as $ pattern => $ target ) { if ( $ pattern == '.' && is_callable ( $ target ) ) { call_user_func ( $ target , $ map ) ; } else { $ params = is_array ( $ target ) ? $ target : explode ( ':' , $ target ) ; $ controller_name = $ app_controller_prefix . $ params [ 0 ] ; $ action = $ params [ 1 ] . 'Action' ; $ bind_name = isset ( $ params [ 2 ] ) ? $ params [ 2 ] : false ; $ method = isset ( $ params [ 4 ] ) ? strtolower ( $ params [ 4 ] ) : 'get|post' ; $ tmp = $ map -> match ( $ pattern , $ controller_name . '::' . $ action ) -> method ( $ method ) ; if ( $ bind_name ) { $ tmp -> bind ( $ bind_name ) ; } if ( ! empty ( $ params [ 3 ] ) ) { if ( is_array ( $ params [ 3 ] ) ) { foreach ( $ params [ 3 ] as $ key => $ value ) { $ tmp -> value ( $ key , $ value ) ; } } else { $ defaults = explode ( ',' , $ params [ 3 ] ) ; foreach ( $ defaults as $ default ) { $ values = explode ( '=' , $ default ) ; $ tmp -> value ( $ values [ 0 ] , $ values [ 1 ] ) ; } } } if ( $ prefix_locale != '' && $ prefix == '/' && $ pattern == '/' ) { $ app -> match ( '/' , $ controller_name . '::' . $ action ) -> method ( $ method ) ; } } } $ app -> mount ( $ prefix_locale . $ prefix , $ map ) ; } } } | Load routing . |
46,847 | public function setLoader ( Loader $ loader ) { $ this -> loader = $ loader ; $ this -> loader -> setNamespace ( $ this -> getNamespace ( ) ) ; } | Set configuration factory loader . |
46,848 | private function getSerializerValSourceExtBasedOn ( ValueSourceExtension $ ext ) { return new SerializerValueSourceExtensionImpl ( $ ext -> getMapper ( ) , $ ext -> getSupportedValueSourceClass ( ) , $ ext -> getUniqueExtensionId ( ) ) ; } | Converts a general value source extension into an extension accepted by the mapper . |
46,849 | public function getTitle ( $ code ) { if ( ! isset ( $ this -> titles [ $ code ] ) ) { $ code = key ( $ this -> getTitles ( ) ) ; } return $ this -> titles [ $ code ] ; } | Return localized title . |
46,850 | public function getSignatureContent ( \ TYPO3 \ Flow \ Http \ Request $ httpRequest ) { $ date = $ httpRequest -> getHeader ( 'Date' ) ; $ dateValue = $ date instanceof \ DateTime ? $ date -> format ( DATE_RFC2822 ) : '' ; $ signData = $ httpRequest -> getMethod ( ) . chr ( 10 ) . sha1 ( $ httpRequest -> getContent ( ) ) . chr ( 10 ) . $ httpRequest -> getHeader ( 'Content-Type' ) . chr ( 10 ) . $ dateValue . chr ( 10 ) . $ httpRequest -> getUri ( ) ; return $ signData ; } | Get the content for the signature from the given request |
46,851 | public function assignAttribute ( $ name , $ value ) { $ table = static :: table ( ) ; if ( ! is_object ( $ value ) ) { if ( array_key_exists ( $ name , $ table -> columns ) ) { $ value = $ table -> columns [ $ name ] -> cast ( $ value , static :: connection ( ) ) ; } else { $ col = $ table -> getColumnByInflectedName ( $ name ) ; if ( ! is_null ( $ col ) ) { $ value = $ col -> cast ( $ value , static :: connection ( ) ) ; } } } if ( $ value instanceof \ DateTime ) { $ value = new DateTime ( $ value -> format ( 'Y-m-d H:i:s T' ) ) ; } if ( $ value instanceof DateTime ) { $ value -> attributeOf ( $ this , $ name ) ; } $ this -> _attributes [ $ name ] = $ value ; $ this -> flagDirty ( $ name ) ; return $ value ; } | Assign a value to an attribute . |
46,852 | public function & readAttribute ( $ name ) { if ( array_key_exists ( $ name , static :: $ aliasAttribute ) ) $ name = static :: $ aliasAttribute [ $ name ] ; if ( array_key_exists ( $ name , $ this -> _attributes ) ) return $ this -> _attributes [ $ name ] ; if ( array_key_exists ( $ name , $ this -> _relationships ) ) return $ this -> _relationships [ $ name ] ; $ table = static :: table ( ) ; if ( ( $ relationship = $ table -> getRelationship ( $ name ) ) ) { $ this -> _relationships [ $ name ] = $ relationship -> load ( $ this ) ; return $ this -> _relationships [ $ name ] ; } if ( $ name == 'id' ) { $ pk = $ this -> getPrimaryKey ( true ) ; if ( isset ( $ this -> _attributes [ $ pk ] ) ) return $ this -> _attributes [ $ pk ] ; } $ null = null ; foreach ( static :: $ delegate as & $ item ) { if ( ( $ delegated_name = $ this -> isDelegated ( $ name , $ item ) ) ) { $ to = $ item [ 'to' ] ; if ( $ this -> $ to ) { $ val = & $ this -> $ to -> __get ( $ delegated_name ) ; return $ val ; } else { return $ null ; } } } throw new UndefinedPropertyException ( get_called_class ( ) , $ name ) ; } | Retrieves an attribute s value or a relationship object based on the name passed . If the attribute accessed is id then it will return the model s primary key no matter what the actual attribute name is for the primary key . |
46,853 | public function hasAttribute ( $ attrName ) { if ( array_key_exists ( $ attrName , $ this -> _attributes ) ) return true ; if ( method_exists ( $ this , "__get_$attrName" ) ) return true ; return false ; } | Check if given attribute exists |
46,854 | public function flagDirty ( $ name , $ dirty = true ) { if ( ! $ this -> _dirty ) $ this -> _dirty = array ( ) ; if ( $ dirty ) { $ this -> _dirty [ $ name ] = true ; } else { if ( array_key_exists ( $ name , $ this -> _dirty ) ) { unset ( $ this -> _dirty [ $ name ] ) ; } } } | Flags an attribute as dirty . |
46,855 | public function dirtyAttributes ( ) { if ( ! $ this -> _dirty ) return null ; $ dirty = array_intersect_key ( $ this -> _attributes , $ this -> _dirty ) ; return ! empty ( $ dirty ) ? $ dirty : null ; } | Returns hash of attributes that have been modified since loading the model . |
46,856 | public function attributeIsDirty ( $ attribute ) { return $ this -> _dirty && isset ( $ this -> _dirty [ $ attribute ] ) && array_key_exists ( $ attribute , $ this -> _attributes ) ; } | Check if a particular attribute has been modified since loading the model . |
46,857 | public static function create ( $ attributes , $ validate = true , $ guardAttributes = true ) { $ className = get_called_class ( ) ; $ model = new $ className ( $ attributes , $ guardAttributes ) ; $ model -> save ( $ validate ) ; return $ model ; } | Creates a model and saves it to the database . |
46,858 | private function insert ( $ validate = true ) { $ this -> verifyNotReadonly ( 'insert' ) ; if ( ( $ validate && ! $ this -> _validate ( ) || ! $ this -> invokeCallback ( 'beforeCreate' , false ) ) ) { return false ; } $ table = static :: table ( ) ; if ( ! ( $ attributes = $ this -> dirtyAttributes ( ) ) ) { $ attributes = $ this -> _attributes ; } $ pk = $ this -> getPrimaryKey ( true ) ; $ useSequence = false ; if ( $ table -> sequence && ! isset ( $ attributes [ $ pk ] ) ) { if ( ( $ conn = static :: connection ( ) ) instanceof OciAdapter ) { $ attributes [ $ pk ] = $ conn -> getNextSequenceValue ( $ table -> sequence ) ; $ table -> insert ( $ attributes ) ; $ this -> _attributes [ $ pk ] = $ attributes [ $ pk ] ; } else { if ( array_key_exists ( $ pk , $ attributes ) ) { unset ( $ attributes [ $ pk ] ) ; } $ table -> insert ( $ attributes , $ pk , $ table -> sequence ) ; $ useSequence = true ; } } else { $ table -> insert ( $ attributes ) ; } { $ column = $ table -> getColumnByInflectedName ( $ pk ) ; if ( $ column -> autoIncrement || $ useSequence ) { $ this -> _attributes [ $ pk ] = static :: connection ( ) -> insertId ( $ table -> sequence ) ; } } $ this -> _newRecord = false ; $ this -> invokeCallback ( 'afterCreate' , false ) ; return true ; } | Issue an INSERT sql statement for this model s attribute . |
46,859 | private function update ( $ validate = true ) { $ this -> verifyNotReadonly ( 'update' ) ; if ( $ validate && ! $ this -> _validate ( ) ) { return false ; } if ( $ this -> isDirty ( ) ) { $ pk = $ this -> valuesForPk ( ) ; if ( empty ( $ pk ) ) { throw new ActiveRecordException ( "Cannot update, no primary key defined for: " . get_called_class ( ) ) ; } if ( ! $ this -> invokeCallback ( 'beforeUpdate' , false ) ) { return false ; } $ dirty = $ this -> dirtyAttributes ( ) ; static :: table ( ) -> update ( $ dirty , $ pk ) ; $ this -> invokeCallback ( 'afterUpdate' , false ) ; } return true ; } | Issue an UPDATE sql statement for this model s dirty attributes . |
46,860 | public function delete ( ) { $ this -> verifyNotReadonly ( 'delete' ) ; $ pk = $ this -> valuesForPk ( ) ; if ( empty ( $ pk ) ) throw new ActiveRecordException ( "Cannot delete, no primary key defined for: " . get_called_class ( ) ) ; if ( ! $ this -> invokeCallback ( 'beforeDestroy' , false ) ) return false ; static :: table ( ) -> delete ( $ pk ) ; $ this -> invokeCallback ( 'afterDestroy' , false ) ; return true ; } | Deletes this model from the database and returns true if successful . |
46,861 | public function valuesFor ( $ attributeNames ) { $ filter = array ( ) ; foreach ( $ attributeNames as $ name ) $ filter [ $ name ] = $ this -> $ name ; return $ filter ; } | Helper to return a hash of values for the specified attributes . |
46,862 | protected function _validate ( ) { if ( static :: $ validates === false ) return true ; if ( is_null ( static :: $ _validation ) ) { require_once ( "Validation/Validation.php" ) ; static :: $ _validation = Validation \ Validation :: onModel ( get_called_class ( ) ) ; } $ result = static :: $ _validation -> validate ( $ this ) ; if ( $ result -> success == false ) { $ this -> _errors = $ result -> errors ; return false ; } else { $ this -> _errors = null ; } return true ; } | Validates the model . |
46,863 | public function setTimestamps ( ) { $ now = date ( 'Y-m-d H:i:s' ) ; if ( isset ( $ this -> updated_at ) ) $ this -> updated_at = $ now ; if ( isset ( $ this -> created_at ) && $ this -> isNewRecord ( ) ) $ this -> created_at = $ now ; } | Updates a model s timestamps . |
46,864 | public function updateAttribute ( $ name , $ value ) { $ this -> __set ( $ name , $ value ) ; return $ this -> update ( false ) ; } | Updates a single attribute and saves the record without going through the normal validation procedure . |
46,865 | public function reload ( ) { $ this -> _relationships = array ( ) ; $ pk = array_values ( $ this -> getValuesFor ( $ this -> getPrimaryKey ( ) ) ) ; $ this -> setAttributesViaMassAssignment ( $ this -> find ( $ pk ) -> attributes , false ) ; $ this -> resetDirty ( ) ; return $ this ; } | Reloads the attributes and relationships of this object from the database . |
46,866 | public static function count ( ) { $ args = func_get_args ( ) ; $ options = static :: extractAndValidateOptions ( $ args ) ; $ options [ 'select' ] = 'COUNT(*)' ; if ( ! empty ( $ args ) && ! is_null ( $ args [ 0 ] ) && ! empty ( $ args [ 0 ] ) ) { if ( is_hash ( $ args [ 0 ] ) ) $ options [ 'conditions' ] = $ args [ 0 ] ; else $ options [ 'conditions' ] = call_user_func_array ( 'static::pk_conditions' , $ args ) ; } $ table = static :: table ( ) ; $ sql = $ table -> options_to_sql ( $ options ) ; $ values = $ sql -> get_where_values ( ) ; return static :: connection ( ) -> query_and_fetch_one ( $ sql -> to_s ( ) , $ values ) ; } | Get a count of qualifying records . |
46,867 | public static function find ( ) { $ class = get_called_class ( ) ; if ( func_num_args ( ) <= 0 ) throw new RecordNotFound ( "Couldn't find $class without an ID" ) ; $ args = func_get_args ( ) ; $ options = static :: extractAndValidateOptions ( $ args ) ; $ num_args = count ( $ args ) ; $ single = true ; if ( $ num_args > 0 && ( $ args [ 0 ] === 'all' || $ args [ 0 ] === 'first' || $ args [ 0 ] === 'last' ) ) { switch ( $ args [ 0 ] ) { case 'all' : $ single = false ; break ; case 'last' : if ( ! array_key_exists ( 'order' , $ options ) ) $ options [ 'order' ] = join ( ' DESC, ' , static :: table ( ) -> pk ) . ' DESC' ; else $ options [ 'order' ] = SQLBuilder :: reverseOrder ( $ options [ 'order' ] ) ; case 'first' : $ options [ 'limit' ] = 1 ; $ options [ 'offset' ] = 0 ; break ; } $ args = array_slice ( $ args , 1 ) ; $ num_args -- ; } elseif ( 1 === count ( $ args ) && 1 == $ num_args ) $ args = $ args [ 0 ] ; if ( $ num_args > 0 && ! isset ( $ options [ 'conditions' ] ) ) return static :: findByPk ( $ args , $ options ) ; $ options [ 'mappedNames' ] = static :: $ aliasAttribute ; $ list = static :: table ( ) -> find ( $ options ) ; return $ single ? ( ! empty ( $ list ) ? $ list [ 0 ] : null ) : $ list ; } | Find records in the database . |
46,868 | public static function findByPk ( $ values , $ options ) { $ options [ 'conditions' ] = static :: pkConditions ( $ values ) ; $ list = static :: table ( ) -> find ( $ options ) ; $ results = count ( $ list ) ; if ( $ results != ( $ expected = count ( $ values ) ) ) { $ class = get_called_class ( ) ; if ( $ expected == 1 ) { if ( ! is_array ( $ values ) ) $ values = array ( $ values ) ; throw new RecordNotFound ( "Couldn't find $class with ID=" . join ( ',' , $ values ) ) ; } $ values = join ( ',' , $ values ) ; throw new RecordNotFound ( "Couldn't find all $class with IDs ($values) (found $results, but was looking for $expected)" ) ; } return $ expected == 1 ? $ list [ 0 ] : $ list ; } | Finder method which will find by a single or array of primary keys for this model . |
46,869 | public static function isOptionsHash ( $ array , $ throw = true ) { if ( Arry :: isHash ( $ array ) ) { $ keys = array_keys ( $ array ) ; $ diff = array_diff ( $ keys , self :: $ validOptions ) ; if ( ! empty ( $ diff ) && $ throw ) { throw new ActiveRecordException ( "Unknown key(s): " . join ( ', ' , $ diff ) ) ; } $ intersect = array_intersect ( $ keys , self :: $ validOptions ) ; if ( ! empty ( $ intersect ) ) { return true ; } } return false ; } | Determines if the specified array is a valid ActiveRecord options array . |
46,870 | private function invokeCallback ( $ method_name , $ must_exist = true ) { return static :: table ( ) -> callback -> invoke ( $ this , $ method_name , $ must_exist ) ; } | Invokes the specified callback on this model . |
46,871 | public static function transaction ( $ closure ) { $ connection = static :: connection ( ) ; try { $ connection -> transaction ( ) ; if ( $ closure ( ) === false ) { $ connection -> rollback ( ) ; return false ; } else $ connection -> commit ( ) ; } catch ( \ Exception $ e ) { $ connection -> rollback ( ) ; throw $ e ; } return true ; } | Executes a block of code inside a database transaction . |
46,872 | public function isFromRoute ( $ routeName ) { $ session = $ this -> getSession ( ) ; if ( $ session -> data === null || ! is_array ( $ session -> source ) ) { return null ; } return $ session -> source [ 'routeName' ] === $ routeName ; } | Indicates whether current data from the specified route name . |
46,873 | public function removeData ( ) { $ session = $ this -> getSession ( ) ; if ( $ session -> data !== null ) { unset ( $ session -> data ) ; return true ; } return false ; } | Remove current route data . |
46,874 | public function generate ( Module $ module , $ modelName , array $ arrayValues ) { $ modelClass = $ module -> getNamespace ( ) . '\\Model\\' . $ modelName ; $ modelPath = $ module -> getPath ( ) . '/Model/' . str_replace ( '\\' , '/' , $ modelName ) . '.php' ; $ modelCode = $ this -> generateCode ( $ module , $ modelName , $ arrayValues ) ; if ( file_exists ( $ modelPath ) ) { throw new \ RuntimeException ( sprintf ( 'Model "%s" already exists.' , $ modelClass ) ) ; } $ this -> explorer -> mkdir ( dirname ( $ modelPath ) ) ; file_put_contents ( $ modelPath , $ modelCode ) ; } | Generate PDO Model |
46,875 | protected function generateCode ( Module $ module , $ modelName , $ arrayValues ) { $ replaces = array ( '<namespace>' => 'namespace ' . $ module -> getNamespace ( ) . '\\Model;' , '<modelAnnotation>' => $ this -> generateDocBlock ( $ modelName ) , '<modelClassName>' => $ modelName , '<construct>' => self :: $ constructorMethodTemplate , '<modelBody>' => $ this -> generateBody ( $ modelName , $ arrayValues ) , '<spaces>' => " " , '<table>' => strtolower ( $ modelName ) ) ; $ classTemplate = str_replace ( array_keys ( $ replaces ) , array_values ( $ replaces ) , self :: $ classTemplate ) ; return $ classTemplate ; } | Generate model class code |
46,876 | public function fileNameStrategy ( $ database , $ name ) { $ name = join ( '_' , array_map ( 'lcfirst' , preg_split ( '/(?=[A-Z])/' , $ name ) ) ) ; return $ database . DS . $ this -> generateVersion ( ) . $ name . '.php' ; } | migration file name adjusting |
46,877 | public function style ( ) : Style { $ type = StyleType :: get ( $ this -> style ) ; return StyleFactory :: factory ( $ type ) -> lineWidth ( $ this -> lineWidth ) ; } | Devuelve el estilo |
46,878 | public function value ( ) : ? string { if ( is_empty ( $ this -> key ) ) { return $ this -> original ; } $ value = $ this -> replacements -> get ( $ this -> key , null ) ; return $ this -> convertToString ( $ value ) ; } | Devuelve el valor |
46,879 | public function width ( ) : int { $ lines = explode ( "\n" , $ this -> value ( ) ) ; $ width = [ ] ; foreach ( $ lines as $ line ) { $ raw = strip_tags ( $ line ) ; $ width [ ] = strlen ( trim ( $ raw ) ) ; } return max ( $ width ) ; } | Devuelve el ancho del token |
46,880 | public function setUserId ( $ userId ) { $ this -> _user = null ; $ this -> userId = ( ( int ) $ userId ) ? : null ; return $ this ; } | Set user - id |
46,881 | protected function getUserMapper ( ) { if ( null === $ this -> _userMapper ) { $ mapper = $ this -> getMapper ( ) ; $ this -> _userMapper = $ this -> getServiceLocator ( ) -> get ( 'Di' ) -> get ( 'Grid\User\Model\User\Mapper' , array ( 'dbAdapter' => $ mapper -> getDbAdapter ( ) , 'dbSchema' => $ mapper -> getDbSchema ( ) , ) ) ; } return $ this -> _userMapper ; } | Get user mapper |
46,882 | public function setPublishedFrom ( $ date , $ format = null ) { $ this -> publishedFrom = empty ( $ date ) ? null : $ this -> inputDate ( $ date , $ format ) ; return $ this ; } | Set published - from date |
46,883 | public function setPublishedTo ( $ date , $ format = null ) { $ this -> publishedTo = empty ( $ date ) ? null : $ this -> inputDate ( $ date , $ format ) ; return $ this ; } | Set published - to date |
46,884 | public function isPublished ( $ now = null ) { if ( ! $ this -> published ) { return false ; } if ( empty ( $ now ) ) { $ now = new DateTime ( ) ; } else { $ now = $ this -> inputDate ( $ now ) ; } if ( ! empty ( $ this -> publishedTo ) && ! $ this -> publishedTo -> diff ( $ now ) -> invert ) { return false ; } if ( ! empty ( $ this -> publishedFrom ) && $ this -> publishedFrom -> diff ( $ now ) -> invert ) { return false ; } return true ; } | Is published at a given time point |
46,885 | public function setAccessUsers ( $ users ) { $ this -> accessUsers = array_unique ( is_array ( $ users ) ? $ users : preg_split ( '/[,\s]+/' , $ users ) ) ; return $ this ; } | Set access users |
46,886 | public function setAccessGroups ( $ groups ) { $ this -> accessGroups = array_unique ( is_array ( $ groups ) ? $ groups : preg_split ( '/[,\s]+/' , $ groups ) ) ; return $ this ; } | Set access groups |
46,887 | public function setEditUsers ( $ users ) { $ this -> editUsers = array_unique ( is_array ( $ users ) ? $ users : preg_split ( '/[,\s]+/' , $ users ) ) ; return $ this ; } | Set edit users |
46,888 | public function setEditGroups ( $ groups ) { $ this -> editGroups = array_unique ( is_array ( $ groups ) ? $ groups : preg_split ( '/[,\s]+/' , $ groups ) ) ; return $ this ; } | Set edit groups |
46,889 | public function getSeoUri ( ) { if ( ! empty ( $ this -> _seoUri ) ) { return $ this -> _seoUri ; } if ( empty ( $ this -> id ) ) { return '' ; } if ( empty ( $ this -> _seoUri ) ) { $ this -> _seoUriStructure = $ this -> getUriStructure ( array ( $ this -> getMapper ( ) -> getLocale ( ) ) ) ; if ( ! empty ( $ this -> _seoUriStructure ) ) { $ this -> _seoUri = $ this -> _seoUriStructure -> uri ; } } return $ this -> _seoUri ; } | Get seo - friendly uri |
46,890 | public function getUri ( ) { if ( $ this -> hasChildren ( ) ) { foreach ( $ this -> getChildren ( ) as $ child ) { $ uri = $ child -> getUri ( ) ; if ( '#' != $ uri [ 0 ] ) { return $ uri ; } } } else { return '#' ; } } | Get URI of this menu - item |
46,891 | public function execute ( ) { $ returnValues = array ( ) ; while ( $ execute = array_shift ( $ this -> executeParameters ) ) { $ returnValues [ ] = $ this -> run ( $ execute ) ; } return $ returnValues ; } | This will execute all the actions in the queue . It will not clear the queue! |
46,892 | public function undo ( ) { $ returnValues = array ( ) ; while ( $ undo = array_shift ( $ this -> undoParameters ) ) { $ returnValues [ ] = $ this -> run ( $ undo ) ; } return $ returnValues ; } | This will execute all the undo actions in the queue . It will not clear the queue! |
46,893 | protected function run ( $ call ) { if ( ! isset ( $ call [ 'callable' ] ) ) { throw new OperationStateException ( "\$call['callable'] was not set" ) ; } if ( ! isset ( $ call [ 'arguments' ] ) ) { try { is_null ( $ call [ 'arguments' ] ) ; } catch ( \ Exception $ e ) { throw new OperationStateException ( "\$call['arguments'] was not set" ) ; } } if ( is_callable ( $ call [ 'callable' ] ) ) { if ( $ call [ 'arguments' ] == self :: NO_ARGUMENT ) { return call_user_func ( $ call [ 'callable' ] ) ; } else { return call_user_func_array ( $ call [ 'callable' ] , $ call [ 'arguments' ] ) ; } } else { throw new OperationStateException ( "\$call and \$arguments passed did not pass is_callable() check" ) ; } } | This will run the action passed whether execute or undo . |
46,894 | public function getKey ( ) { if ( ! isset ( $ this -> key ) ) { $ this -> key = md5 ( microtime ( ) . rand ( ) ) ; } return $ this -> key ; } | Get the a unique key for this object . It should return the same value regardless of when this function is called! |
46,895 | public function getFile ( Repo $ repo ) { $ file = tempnam ( sys_get_temp_dir ( ) , 'composer' ) ; $ content = file_get_contents ( $ this -> helper -> getRawFileUrl ( $ repo -> getSlug ( ) , 'master' , 'composer.json' ) ) ; file_put_contents ( $ file , $ content ) ; return $ file ; } | Get composer file |
46,896 | private function calculateTotalAmountForDeliveryExpenses ( Transaction $ transaction ) { $ total = 0 ; foreach ( $ transaction -> getItems ( ) as $ productPurchase ) { if ( $ productPurchase -> getProduct ( ) instanceof Product ) { if ( ! $ productPurchase -> getProduct ( ) -> isFreeTransport ( ) ) { $ addPercent = 0 ; if ( $ this -> deliveryExpensesPercentage > 0 ) $ addPercent = $ productPurchase -> getTotalPrice ( ) * $ this -> deliveryExpensesPercentage ; $ total += $ productPurchase -> getTotalPrice ( ) + $ addPercent ; } } else { $ total += $ productPurchase -> getTotalPrice ( ) ; } } return $ total ; } | Calculate total amount for delivery expenses |
46,897 | public function getCurrentTransaction ( ) { if ( false === $ this -> session -> has ( 'transaction-id' ) ) { throw new AccessDeniedHttpException ( ) ; } return $ this -> manager -> getRepository ( 'EcommerceBundle:Transaction' ) -> find ( $ this -> session -> get ( 'transaction-id' ) ) ; } | Get current transaction |
46,898 | public function updateTransaction ( ) { $ cart = $ this -> cartProvider -> getCart ( ) ; if ( 0 === $ cart -> countItems ( ) || $ this -> isTransactionUpdated ( $ cart ) ) { return ; } $ transactionRepository = $ this -> manager -> getRepository ( 'EcommerceBundle:Transaction' ) ; if ( $ this -> session -> has ( 'transaction-id' ) ) { $ transaction = $ transactionRepository -> find ( $ this -> session -> get ( 'transaction-id' ) ) ; $ transactionRepository -> removeItems ( $ transaction ) ; } else { $ transactionKey = $ transactionRepository -> getNextNumber ( ) ; $ transaction = new Transaction ( ) ; $ transaction -> setTransactionKey ( $ transactionKey ) ; $ transaction -> setStatus ( Transaction :: STATUS_CREATED ) ; $ transaction -> setActor ( $ this -> securityContext -> getToken ( ) -> getUser ( ) ) ; $ cartItem = $ cart -> getItems ( ) -> first ( ) ; $ product = $ cartItem -> getProduct ( ) ; } $ orderTotalPrice = 0 ; foreach ( $ cart -> getItems ( ) as $ cartItem ) { $ product = $ cartItem -> getProduct ( ) ; $ productPurchase = new ProductPurchase ( ) ; $ productPurchase -> setProduct ( $ product ) ; $ productPurchase -> setBasePrice ( $ cartItem -> getUnitPrice ( ) ) ; $ productPurchase -> setQuantity ( $ cartItem -> getQuantity ( ) ) ; $ productPurchase -> setDiscount ( $ product -> getDiscount ( ) ) ; $ productPurchase -> setTotalPrice ( $ cartItem -> getTotal ( ) ) ; $ productPurchase -> setTransaction ( $ transaction ) ; $ productPurchase -> setReturned ( false ) ; if ( $ cartItem -> isFreeTransport ( ) ) { $ productPurchase -> setDeliveryExpenses ( 0 ) ; } else { $ productPurchase -> setDeliveryExpenses ( $ cartItem -> getShippingCost ( ) ) ; } $ orderTotalPrice += $ cartItem -> getProduct ( ) -> getPrice ( ) * $ cartItem -> getQuantity ( ) ; $ this -> manager -> persist ( $ productPurchase ) ; } $ transaction -> setTotalPrice ( $ orderTotalPrice ) ; $ this -> manager -> persist ( $ transaction ) ; $ this -> manager -> flush ( ) ; $ this -> session -> set ( 'transaction-id' , $ transaction -> getId ( ) ) ; $ this -> session -> save ( ) ; } | Update transaction with cart s contents |
46,899 | private function isTransactionUpdated ( Cart $ cart ) { if ( false === $ this -> session -> has ( 'transaction-id' ) ) { return false ; } $ transactionRepository = $ this -> manager -> getRepository ( 'EcommerceBundle:Transaction' ) ; $ transaction = $ transactionRepository -> find ( $ this -> session -> get ( 'transaction-id' ) ) ; $ cartItems = $ cart -> getItems ( ) ; $ productPurchases = $ transaction -> getItems ( ) ; if ( $ cartItems -> count ( ) !== $ productPurchases -> count ( ) ) { return false ; } for ( $ i = 0 ; $ i < $ cartItems -> count ( ) ; $ i ++ ) { $ cartItem = $ cartItems [ $ i ] ; $ productPurchase = $ productPurchases [ $ i ] ; if ( $ cartItem -> getProduct ( ) -> getId ( ) !== $ productPurchase -> getProduct ( ) -> getId ( ) || $ cartItem -> getQuantity ( ) !== $ productPurchase -> getQuantity ( ) ) { return false ; } } return true ; } | Compare current cart with current transaction |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.