idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
53,300 | public function serialize ( ) { $ request = $ this -> requestStack -> getCurrentRequest ( ) ; $ logo = $ this -> fileUtilities -> getOneBy ( [ 'url' => $ this -> config -> getParameter ( 'logo' ) , ] ) ; return [ 'maintenance' => MaintenanceHandler :: isMaintenanceEnabled ( ) , 'logo' => $ logo ? [ 'url' => $ logo -> g... | Serializes required information for FrontEnd rendering . |
53,301 | public function getHTMLFiles ( $ directory ) { try { $ dir = new RecursiveDirectoryIterator ( $ directory , RecursiveDirectoryIterator :: SKIP_DOTS | RecursiveDirectoryIterator :: NEW_CURRENT_AND_KEY ) ; $ files = new \ RecursiveIteratorIterator ( $ dir ) ; $ allowedExtensions = [ 'htm' , 'html' ] ; $ list = [ ] ; fore... | Get all HTML files from a zip archive . |
53,302 | public function guessRootFile ( UploadedFile $ file , Workspace $ workspace ) { $ zipPath = $ this -> container -> getParameter ( 'claroline.param.uploads_directory' ) . DIRECTORY_SEPARATOR . 'webresource' . DIRECTORY_SEPARATOR . $ workspace -> getUuid ( ) . DIRECTORY_SEPARATOR ; if ( ! $ this -> getZip ( ) -> open ( $... | Try to retrieve root file of the WebResource from the zip archive . |
53,303 | public function guessRootFileFromUnzipped ( $ hash ) { $ htmlFiles = $ this -> getHTMLFiles ( $ hash ) ; if ( 1 === count ( $ htmlFiles ) ) { return array_shift ( $ htmlFiles ) ; } foreach ( $ this -> defaultIndexFiles as $ file ) { if ( in_array ( $ file , $ htmlFiles ) ) { return $ file ; } } return ; } | Try to retrieve root file of the WebResource from the unzipped directory . |
53,304 | public function isZip ( UploadedFile $ file , $ workspace ) { $ isZip = false ; if ( 'application/zip' === $ file -> getClientMimeType ( ) || true === $ this -> getZip ( ) -> open ( $ file ) ) { $ rootFile = $ this -> guessRootFile ( $ file , $ workspace ) ; if ( ! empty ( $ rootFile ) ) { $ isZip = true ; } } return $... | Checks if a UploadedFile is a zip and contains index . html file . |
53,305 | public function unzip ( $ hash , Workspace $ workspace ) { $ filesPath = $ this -> container -> getParameter ( 'claroline.param.files_directory' ) . DIRECTORY_SEPARATOR . 'webresource' . DIRECTORY_SEPARATOR . $ workspace -> getUuid ( ) . DIRECTORY_SEPARATOR ; $ zipPath = $ this -> container -> getParameter ( 'claroline... | Unzips files in web directory . |
53,306 | public function findByUserAndCompetencyIds ( User $ user , array $ competencyIds ) { if ( 0 === count ( $ competencyIds ) ) { return [ ] ; } return $ this -> createQueryBuilder ( 'p' ) -> select ( 'p' , 'c' ) -> join ( 'p.competency' , 'c' ) -> where ( 'p.user = :user' ) -> andWhere ( ( new Expr ( ) ) -> in ( 'p.compet... | Returns every competency progress entity related to a given user and whose id is in a given set . |
53,307 | public function removeUsedHint ( $ hintId ) { $ pos = array_search ( $ hintId , $ this -> usedHints ) ; if ( false !== $ pos ) { array_splice ( $ this -> usedHints , $ pos , 1 ) ; } } | Removes an Hint . |
53,308 | public function onLoad ( LoadResourceEvent $ event ) { $ lesson = $ event -> getResource ( ) ; $ firstChapter = $ this -> chapterRepository -> getFirstChapter ( $ lesson ) ; $ root = $ this -> chapterRepository -> findOneBy ( [ 'lesson' => $ lesson , 'level' => 0 , 'parent' => null ] ) ; $ event -> setData ( [ 'exportP... | Loads a lesson . |
53,309 | public function indexAction ( ) { $ this -> checkAccess ( ) ; $ allowWorkspace = $ this -> configHandler -> getParameter ( 'allow_workspace_at_registration' ) ; $ data = [ 'facets' => $ this -> profileSerializer -> serialize ( [ Options :: REGISTRATION ] ) , 'termOfService' => $ this -> configHandler -> getParameter ( ... | Displays the user self - registration form . |
53,310 | public function writeMigrationClass ( Bundle $ bundle , $ driverName , $ version , array $ queries ) { if ( ! $ this -> hasSqlExtension ) { $ this -> twigEnvironment -> addExtension ( new SqlFormatterExtension ( ) ) ; $ this -> hasSqlExtension = true ; } $ targetDir = "{$bundle->getPath()}/Migrations/{$driverName}" ; $... | Writes a bundle migration class for a given driver . |
53,311 | public function deleteUpperMigrationClasses ( Bundle $ bundle , $ driverName , $ referenceVersion ) { $ migrations = new \ DirectoryIterator ( "{$bundle->getPath()}/Migrations/{$driverName}" ) ; $ deletedVersions = array ( ) ; foreach ( $ migrations as $ migration ) { if ( preg_match ( '#Version(\d+)\.php#' , $ migrati... | Deletes bundle migration classes for a given driver which are above a reference version . |
53,312 | public function addUsersToGroup ( Group $ group , array $ users ) { $ addedUsers = [ ] ; if ( ! $ this -> validateAddUsersToGroup ( $ users , $ group ) ) { throw new Exception \ AddRoleException ( ) ; } foreach ( $ users as $ user ) { if ( ! $ group -> containsUser ( $ user ) ) { $ addedUsers [ ] = $ user ; $ group -> ... | Adds an array of user to a group . |
53,313 | public function setPlatformRoles ( Group $ group , $ roles ) { foreach ( $ group -> getPlatformRoles ( ) as $ role ) { $ group -> removeRole ( $ role ) ; } $ this -> om -> persist ( $ group ) ; $ this -> roleManager -> associateRoles ( $ group , $ roles ) ; $ this -> om -> flush ( ) ; } | Sets an array of platform role to a group . |
53,314 | public function getCsvAnswers ( AbstractItem $ item , Answer $ answer ) { $ data = json_decode ( $ answer -> getData ( ) , true ) ; $ answers = [ ] ; foreach ( $ item -> getChoices ( ) as $ choice ) { if ( is_array ( $ data ) && in_array ( $ choice -> getUuid ( ) , $ data ) ) { $ answers [ ] = $ choice -> getData ( ) ;... | Exports choice answers . |
53,315 | public function update ( Theme $ theme , array $ data ) { $ errors = $ this -> validate ( $ data ) ; if ( count ( $ errors ) > 0 ) { throw new InvalidDataException ( 'Theme is not valid' , $ errors ) ; } $ this -> serializer -> deserialize ( $ data , $ theme ) ; $ this -> om -> persist ( $ theme ) ; $ this -> om -> flu... | Updates an existing theme . |
53,316 | public function deleteBulk ( array $ themes , User $ user ) { $ toDelete = $ this -> repository -> findByUuids ( $ themes ) ; $ this -> om -> startFlushSuite ( ) ; foreach ( $ toDelete as $ theme ) { $ this -> delete ( $ theme , $ user , true ) ; } $ this -> om -> endFlushSuite ( ) ; } | Deletes a Theme . It s only possible if the User owns it . |
53,317 | public function all ( $ onlyEnabled = false ) { $ themes = $ this -> repository -> findAll ( ) ; if ( $ onlyEnabled ) { $ themes = array_filter ( $ themes , function ( $ theme ) { return $ theme -> isEnabled ( ) ; } ) ; $ pm = $ this -> pm ; $ themes = array_filter ( $ themes , function ( $ theme ) use ( $ pm ) { retur... | Lists all themes installed in the current platform . |
53,318 | public function addDefinition ( ItemDefinitionInterface $ definition ) { if ( ! is_string ( $ definition -> getMimeType ( ) ) ) { throw UnregisterableDefinitionException :: notAStringMimeType ( $ definition ) ; } if ( ! in_array ( $ definition -> getMimeType ( ) , ItemType :: getList ( ) ) ) { throw UnregisterableDefin... | Adds a item definition to the collection . |
53,319 | public function addContentItemDefinition ( ContentItemDefinition $ definition ) { if ( ! is_string ( $ definition -> getMimeType ( ) ) ) { throw UnregisterableDefinitionException :: notAStringMimeType ( $ definition ) ; } if ( ! in_array ( $ definition -> getMimeType ( ) , ItemType :: getList ( ) ) ) { throw Unregister... | Adds a content item definition to the collection . |
53,320 | public function get ( $ type ) { if ( isset ( $ this -> definitions [ $ type ] ) ) { return $ this -> definitions [ $ type ] ; } throw new UnregisteredDefinitionException ( $ type , UnregisteredDefinitionException :: TARGET_MIME_TYPE ) ; } | Returns the definition for a specific MIME type if any . |
53,321 | public function getConvertedType ( $ mimeType ) { $ type = $ mimeType ; if ( 1 !== preg_match ( '#^application\/x\.[^/]+\+json$#' , $ mimeType ) && 1 === preg_match ( '#^[^/]+\/[^/]+$#' , $ mimeType ) ) { $ type = 'content' ; } return $ type ; } | Converts mime - type to a supported format . |
53,322 | public function openResourceAction ( $ node ) { $ resourceNode = $ this -> container -> get ( 'claroline.persistence.object_manager' ) -> find ( ResourceNode :: class , $ node ) ; return $ this -> redirectToRoute ( 'claro_resource_show' , [ 'id' => $ resourceNode -> getUuid ( ) , 'type' => $ resourceNode -> getResource... | Renders a resource application . Used for old links compatibility . |
53,323 | public function listAction ( Exercise $ exercise , User $ user , Request $ request ) { $ this -> assertHasPermission ( 'OPEN' , $ exercise ) ; $ params = $ request -> query -> all ( ) ; $ params [ 'hiddenFilters' ] = [ ] ; $ params [ 'hiddenFilters' ] [ 'exercise' ] = $ exercise -> getId ( ) ; $ serializationOptions = ... | Returns all the papers associated with an exercise . Administrators get the papers of all users others get only theirs . |
53,324 | public function getAction ( Exercise $ exercise , Paper $ paper , User $ user ) { $ this -> assertHasPermission ( 'OPEN' , $ exercise ) ; if ( ! $ this -> isAdmin ( $ paper -> getExercise ( ) ) && $ paper -> getUser ( ) !== $ user ) { throw new AccessDeniedException ( ) ; } return new JsonResponse ( $ this -> paperMana... | Returns one paper . Also includes the complete definition and solution of each question associated with the exercise . |
53,325 | public function deleteAction ( Paper $ paper ) { $ this -> assertHasPermission ( 'MANAGE_PAPERS' , $ paper -> getExercise ( ) ) ; try { $ this -> paperManager -> delete ( $ paper ) ; } catch ( InvalidDataException $ e ) { return new JsonResponse ( $ e -> getErrors ( ) , 422 ) ; } return new JsonResponse ( null , 204 ) ... | Deletes a paper from an exercise . |
53,326 | public function exportCsvAction ( Exercise $ exercise ) { $ this -> assertHasPermission ( 'MANAGE_PAPERS' , $ exercise ) ; return new StreamedResponse ( function ( ) use ( $ exercise ) { $ this -> exerciseManager -> exportPapersToCsv ( $ exercise ) ; } , 200 , [ 'Content-Type' => 'application/force-download' , 'Content... | Exports papers into a CSV file . |
53,327 | public function exportJsonAction ( Exercise $ exercise ) { if ( ! $ this -> isAdmin ( $ exercise ) ) { throw new AccessDeniedException ( ) ; } $ response = new StreamedResponse ( function ( ) use ( $ exercise ) { $ data = $ this -> paperManager -> serializeExercisePapers ( $ exercise ) ; $ handle = fopen ( 'php://outpu... | Exports papers into a json file . |
53,328 | public function exportCsvAnswersAction ( Exercise $ exercise ) { if ( ! $ this -> isAdmin ( $ exercise ) ) { throw new AccessDeniedException ( ) ; } return new StreamedResponse ( function ( ) use ( $ exercise ) { $ this -> exerciseManager -> exportResultsToCsv ( $ exercise ) ; } , 200 , [ 'Content-Type' => 'application... | Exports papers into a csv file . |
53,329 | private function updateSteps ( ) { $ this -> log ( 'Initializing resource node of steps...' ) ; $ om = $ this -> container -> get ( 'claroline.persistence.object_manager' ) ; $ steps = $ om -> getRepository ( 'Innova\PathBundle\Entity\Step' ) -> findAll ( ) ; $ om -> startFlushSuite ( ) ; $ i = 0 ; foreach ( $ steps as... | Initializes Steps resource node from activity resource . |
53,330 | protected function refreshUser ( TokenInterface $ token ) { $ user = $ token -> getUser ( ) ; if ( ! $ user instanceof UserInterface ) { return ; } $ refreshedUser = $ this -> userProvider -> refreshUser ( $ user ) ; $ token -> setUser ( $ refreshedUser ) ; return $ token ; } | Refreshes the user by reloading it from the user provider . This method was copied from Symfony \ Component \ Security \ Http \ Firewall \ ContextListener . |
53,331 | public function addNotation ( \ Innova \ CollecticielBundle \ Entity \ Notation $ notation ) { $ this -> notations [ ] = $ notation ; return $ this ; } | Add notation . |
53,332 | public function removeNotation ( \ Innova \ CollecticielBundle \ Entity \ Notation $ notation ) { $ this -> notations -> removeElement ( $ notation ) ; } | Remove notation . |
53,333 | public function deserialize ( $ data , MatchQuestion $ matchQuestion = null , array $ options = [ ] ) { if ( empty ( $ matchQuestion ) ) { $ matchQuestion = new MatchQuestion ( ) ; } if ( isset ( $ data [ 'penaty' ] ) ) { if ( ! empty ( $ data [ 'penalty' ] ) || 0 === $ data [ 'penalty' ] ) { $ matchQuestion -> setPena... | Converts raw data into a Match question entity . |
53,334 | public function serialize ( ScheduledTask $ scheduledTask ) { return [ 'id' => $ scheduledTask -> getId ( ) , 'type' => $ scheduledTask -> getType ( ) , 'name' => $ scheduledTask -> getName ( ) , 'scheduledDate' => $ scheduledTask -> getScheduledDate ( ) -> format ( 'Y-m-d\TH:i:s' ) , 'data' => $ scheduledTask -> getDa... | Serializes a ScheduledTask entity for the JSON api . |
53,335 | public function deserialize ( array $ data , ScheduledTask $ scheduledTask = null ) { $ scheduledTask = $ scheduledTask ? : new ScheduledTask ( ) ; $ scheduledTask -> setName ( $ data [ 'name' ] ) ; $ scheduledTask -> setType ( $ data [ 'type' ] ) ; $ scheduledDate = \ DateTime :: createFromFormat ( 'Y-m-d\TH:i:s' , $ ... | Deserializes JSON api data into a ScheduledTask entity . |
53,336 | public function generate ( ) { $ tempName = Uuid :: uuid4 ( ) -> toString ( ) ; $ tempFile = $ this -> getDirectory ( ) . DIRECTORY_SEPARATOR . $ tempName ; $ this -> files [ ] = $ tempFile ; return $ tempFile ; } | Generates a new temporary file . |
53,337 | public function clear ( ) { if ( ! empty ( $ this -> files ) ) { $ fs = new FileSystem ( ) ; foreach ( $ this -> files as $ file ) { $ fs -> remove ( $ file ) ; } } } | Removes current temp files . |
53,338 | public function validate ( PluginBundleInterface $ plugin ) { $ validationErrors = [ ] ; foreach ( $ this -> checkers as $ checker ) { if ( null !== $ errors = $ checker -> check ( $ plugin , $ this -> isInUpdateMode ( ) ) ) { $ validationErrors = array_merge ( $ validationErrors , $ errors ) ; continue ; } if ( $ chec... | Validates a plugin . |
53,339 | public function onDisplayWorkspace ( DisplayToolEvent $ event ) { $ workspace = $ event -> getWorkspace ( ) ; $ content = $ this -> templating -> render ( 'ClarolineCoreBundle:workspace:users.html.twig' , [ 'workspace' => $ workspace , 'restrictions' => [ 'hasUserManagementAccess' => $ this -> authorization -> isGrante... | Displays users on Workspace . |
53,340 | public function updateAction ( Exercise $ exercise , Request $ request ) { $ this -> assertHasPermission ( 'EDIT' , $ exercise ) ; $ errors = [ ] ; $ data = $ this -> decodeRequestData ( $ request ) ; if ( null === $ data ) { $ errors [ ] = [ 'path' => '' , 'message' => 'Invalid JSON data' , ] ; } else { try { $ this -... | Updates an Exercise . |
53,341 | public function exportAction ( Exercise $ exercise ) { $ this -> assertHasPermission ( 'ADMINISTRATE' , $ exercise ) ; $ file = $ this -> exerciseManager -> export ( $ exercise ) ; $ response = new StreamedResponse ( ) ; $ response -> setCallBack ( function ( ) use ( $ file ) { readfile ( $ file ) ; } ) ; $ name = $ ex... | download json quiz . |
53,342 | public function docimologyOpenAction ( Exercise $ exercise ) { return [ '_resource' => $ exercise , 'resourceNode' => $ exercise -> getResourceNode ( ) , 'exercise' => $ this -> exerciseManager -> serialize ( $ exercise , [ Transfer :: MINIMAL ] ) , 'statistics' => $ this -> docimologyManager -> getStatistics ( $ exerc... | Opens the docimology of a quiz . |
53,343 | public function statisticsAction ( Exercise $ exercise ) { if ( ! $ exercise -> hasStatistics ( ) ) { $ this -> assertHasPermission ( 'EDIT' , $ exercise ) ; } $ statistics = [ ] ; $ finishedOnly = ! $ exercise -> isAllPapersStatistics ( ) ; foreach ( $ exercise -> getSteps ( ) as $ step ) { foreach ( $ step -> getQues... | Gets statistics of an Exercise . |
53,344 | public function findByCompetency ( Competency $ competency ) { return $ this -> createQueryBuilder ( 'a' ) -> select ( 'a.id' , 'a.name' , 'a.resourceCount' , 'a.minResourceCount' , 'c.id AS competencyId' , 'l.name AS levelName' , 'l.value AS levelValue' ) -> join ( 'a.competencyAbilities' , 'ca' ) -> join ( 'ca.compet... | Returns an array representation of all the abilities linked to a given competency tree . Result includes information about ability level as well . |
53,345 | public function findOthersByCompetencyAndLevel ( Competency $ competency , Level $ level , Ability $ abilityToExclude ) { return $ this -> createQueryBuilder ( 'a' ) -> select ( 'a' ) -> join ( 'a.competencyAbilities' , 'ca' ) -> join ( 'ca.competency' , 'c' ) -> join ( 'ca.level' , 'l' ) -> where ( 'c = :competency' )... | Returns the abilities directly linked to a given competency and a particular level excluding a given ability . |
53,346 | public function findByCompetencyAndLevel ( Competency $ competency , Level $ level ) { return $ this -> createQueryBuilder ( 'a' ) -> select ( 'a' ) -> join ( 'a.competencyAbilities' , 'ca' ) -> join ( 'ca.competency' , 'c' ) -> join ( 'ca.level' , 'l' ) -> where ( 'c = :competency' ) -> andWhere ( 'l = :level' ) -> or... | Returns the abilities directly linked to a given competency and a particular level . |
53,347 | public function deleteOrphans ( ) { $ linkedAbilityIds = $ this -> _em -> createQueryBuilder ( ) -> select ( 'a.id' ) -> distinct ( ) -> from ( 'HeVinci\CompetencyBundle\Entity\CompetencyAbility' , 'ca' ) -> join ( 'ca.ability' , 'a' ) -> getQuery ( ) -> getScalarResult ( ) ; $ qb = $ this -> createQueryBuilder ( 'a' )... | Deletes abilities which are no longer associated with a competency . |
53,348 | public function findFirstByName ( $ name , Competency $ excludedParent ) { $ qb = $ this -> createQueryBuilder ( 'a' ) ; $ qb2 = $ this -> _em -> createQueryBuilder ( ) ; $ qb2 -> select ( 'a2' ) -> from ( 'HeVinci\CompetencyBundle\Entity\CompetencyAbility' , 'ca' ) -> join ( 'ca.ability' , 'a2' ) -> where ( $ qb2 -> e... | Returns the first five abilities whose name begins by a given string excluding abilities linked to a particular competency . |
53,349 | public function findEvaluationsByCompetency ( Competency $ competency , User $ user ) { if ( $ competency -> getRight ( ) - $ competency -> getLeft ( ) > 1 ) { throw new \ Exception ( 'Expected leaf competency' ) ; } $ resourceQb = $ this -> createQueryBuilder ( 'a1' ) -> select ( 'node.id' ) -> join ( 'a1.resources' ,... | Returns an array representation of resource evaluation data for a given user and a given competency including information about the resource and the related abilities . |
53,350 | public function getQuestion ( $ uuid ) { $ found = null ; foreach ( $ this -> stepQuestions as $ stepQuestion ) { if ( $ stepQuestion -> getQuestion ( ) -> getUuid ( ) === $ uuid ) { $ found = $ stepQuestion -> getQuestion ( ) ; break ; } } return $ found ; } | Gets a question by its uuid . |
53,351 | public function addQuestion ( Item $ question ) { $ stepQuestions = $ this -> stepQuestions -> toArray ( ) ; foreach ( $ stepQuestions as $ stepQuestion ) { if ( $ stepQuestion -> getQuestion ( ) === $ question ) { return ; } } $ stepQuestion = new StepItem ( ) ; $ stepQuestion -> setOrder ( $ this -> stepQuestions -> ... | Shortcut to add Items to Step . Avoids the need to manually initialize a StepItem object to hold the relation . |
53,352 | public function listQuestionsToCorrectAction ( Exercise $ exercise ) { $ toCorrect = $ this -> isAdmin ( $ exercise ) ? $ this -> correctionManager -> getToCorrect ( $ exercise ) : [ ] ; return new JsonResponse ( $ toCorrect ) ; } | Lists all questions with manual score rule that have answers to correct . |
53,353 | public function saveAction ( Exercise $ exercise , Request $ request ) { if ( $ this -> isAdmin ( $ exercise ) ) { $ data = $ this -> decodeRequestData ( $ request ) ; if ( null === $ data ) { $ errors [ ] = [ 'path' => '' , 'message' => 'Invalid JSON data' , ] ; } else { try { $ this -> correctionManager -> save ( $ d... | Saves score & feedback for a bulk of answers . |
53,354 | public function getConfigurableRights ( ResourceNode $ node ) { $ existing = $ this -> rightsRepo -> findConfigurableRights ( $ node ) ; $ roles = $ node -> getWorkspace ( ) -> getRoles ( ) ; $ missings = [ ] ; foreach ( $ roles as $ role ) { $ found = false ; foreach ( $ existing as $ right ) { if ( $ right -> getRole... | Returns every ResourceRights of a resource on 1 level if the role linked is not ROLE_ADMIN . |
53,355 | public function getCustomRoleRights ( ResourceNode $ node ) { $ perms = [ ] ; foreach ( $ node -> getRights ( ) as $ right ) { if ( 'ROLE_ANONYMOUS' !== $ right -> getRole ( ) -> getName ( ) && 'ROLE_USER' !== $ right -> getRole ( ) -> getName ( ) ) { $ rolePerms = $ this -> maskManager -> decodeMask ( $ right -> getMa... | Return the resource rights as a readable array . This array can be used for the resource creation . |
53,356 | public function initializePermissions ( array $ nodes , array $ roles ) { $ this -> om -> startFlushSuite ( ) ; foreach ( $ nodes as $ node ) { foreach ( $ roles as $ role ) { $ type = $ node -> getResourceType ( ) ; $ this -> editPerms ( $ type -> getDefaultMask ( ) , $ role , $ node , false ) ; } } $ this -> om -> en... | Initialize the default permissions for a role list . Directories are excluded . |
53,357 | public function isManager ( ResourceNode $ resourceNode ) { $ token = $ this -> tokenStorage -> getToken ( ) ; if ( 'anon.' === $ token ) { return false ; } $ roleNames = array_map ( function ( RoleInterface $ role ) { return $ role -> getRole ( ) ; } , $ token -> getRoles ( ) ) ; $ isWorkspaceUsurp = in_array ( 'ROLE_... | Checks if the current user is a manager of a resource . |
53,358 | public function getCurrentPermissionArray ( ResourceNode $ resourceNode ) { $ currentRoles = $ this -> tokenStorage -> getToken ( ) -> getRoles ( ) ; $ roleNames = array_map ( function ( RoleInterface $ roleName ) { return $ roleName -> getRole ( ) ; } , $ currentRoles ) ; $ creatable = [ ] ; if ( $ this -> isManager (... | maybe use that one in the voter later because it s going to be usefull |
53,359 | public function refreshIdentifiers ( AbstractItem $ item ) { foreach ( $ item -> getColors ( ) as $ color ) { $ color -> refreshUuid ( ) ; } foreach ( $ item -> getSelections ( ) as $ selection ) { $ selection -> refreshUuid ( ) ; } } | Refreshes selections and colors UUIDs . |
53,360 | public function getUpdatedResourceUserEvaluation ( Path $ path ) { $ resourceUserEvaluation = null ; $ user = $ this -> tokenStorage -> getToken ( ) -> getUser ( ) ; if ( $ user instanceof User ) { $ resourceUserEvaluation = $ this -> resourceEvalManager -> getResourceUserEvaluation ( $ path -> getResourceNode ( ) , $ ... | Fetch resource user evaluation with up - to - date status . |
53,361 | public function getResourceUserEvaluation ( Path $ path , User $ user ) { return $ this -> resourceEvalManager -> getResourceUserEvaluation ( $ path -> getResourceNode ( ) , $ user ) ; } | Fetch or create resource user evaluation . |
53,362 | public function generateResourceEvaluation ( Step $ step , User $ user , $ status ) { $ statusData = $ this -> computeResourceUserEvaluation ( $ step -> getPath ( ) , $ user ) ; $ stepIndex = array_search ( $ step -> getUuid ( ) , $ statusData [ 'stepsToDo' ] ) ; if ( false !== $ stepIndex && false !== array_search ( $... | Create a ResourceEvaluation for a step . |
53,363 | public function computeResourceUserEvaluation ( Path $ path , User $ user ) { $ steps = $ path -> getSteps ( ) -> toArray ( ) ; $ stepsUuids = array_map ( function ( Step $ step ) { return $ step -> getUuid ( ) ; } , $ steps ) ; $ resourceUserEval = $ this -> resourceEvalManager -> getResourceUserEvaluation ( $ path ->... | Compute current resource evaluation status . |
53,364 | public function getStepsProgressionForUser ( Path $ path , User $ user ) { $ stepsProgression = [ ] ; foreach ( $ path -> getSteps ( ) as $ step ) { $ userProgression = $ this -> repository -> findOneBy ( [ 'step' => $ step , 'user' => $ user ] ) ; if ( $ userProgression ) { $ stepsProgression [ $ step -> getUuid ( ) ]... | Get all steps progression for an user . |
53,365 | public function serialize ( Keyword $ keyword , array $ options = [ ] ) { $ serialized = [ 'id' => $ keyword -> getUuid ( ) , 'name' => $ keyword -> getName ( ) , ] ; return $ serialized ; } | Serializes a Keyword entity for the JSON api . |
53,366 | public function serialize ( Role $ role , array $ options = [ ] ) { $ serialized = [ 'id' => $ role -> getUuid ( ) , 'name' => $ role -> getName ( ) , 'type' => $ role -> getType ( ) , 'translationKey' => $ role -> getTranslationKey ( ) , ] ; if ( ! in_array ( Options :: SERIALIZE_MINIMAL , $ options ) ) { $ serialized... | Serializes a Role entity . |
53,367 | public function serializeMeta ( Role $ role , array $ options ) { $ meta = [ 'readOnly' => $ role -> isReadOnly ( ) , 'personalWorkspaceCreationEnabled' => $ role -> getPersonalWorkspaceCreationEnabled ( ) , ] ; if ( in_array ( Options :: SERIALIZE_COUNT_USER , $ options ) ) { if ( Role :: USER_ROLE !== $ role -> getTy... | Serialize role metadata . |
53,368 | private function serializeTools ( Role $ role , $ workspaceId ) { $ tools = [ ] ; $ workspace = $ this -> om -> getRepository ( Workspace :: class ) -> findBy ( [ 'uuid' => $ workspaceId ] ) ; $ orderedTools = $ this -> orderedToolRepo -> findBy ( [ 'workspace' => $ workspace ] ) ; foreach ( $ orderedTools as $ ordered... | Serialize role tools rights . |
53,369 | private function serializeDesktopToolsConfig ( Role $ role ) { $ configs = [ ] ; $ desktopTools = $ this -> om -> getRepository ( Tool :: class ) -> findBy ( [ 'isDisplayableInDesktop' => true ] ) ; $ toolsRole = $ this -> om -> getRepository ( ToolRole :: class ) -> findBy ( [ 'role' => $ role ] ) ; foreach ( $ toolsR... | Serialize role configuration for desktop tools . |
53,370 | public function expectAnswer ( AbstractItem $ question ) { $ expected = [ ] ; switch ( $ question -> getSumMode ( ) ) { case GridQuestion :: SUM_CELL : foreach ( $ question -> getCells ( ) -> toArray ( ) as $ cell ) { if ( 0 < count ( $ cell -> getChoices ( ) ) ) { $ expected [ ] = $ this -> findCellExpectedAnswer ( $ ... | Used to compute the question total score . Only for sum score type . |
53,371 | public function serialize ( Chapter $ chapter , array $ options = [ ] ) { $ previousChapter = $ this -> chapterRepository -> getPreviousChapter ( $ chapter ) ; $ nextChapter = $ this -> chapterRepository -> getNextChapter ( $ chapter ) ; $ serialized = [ 'id' => $ chapter -> getUuid ( ) , 'slug' => $ chapter -> getSlug... | Serializes a Chapter entity for the JSON api . |
53,372 | public function connect ( $ server , $ user = null , $ password = null , $ isAuthentication = false ) { if ( $ server && isset ( $ server [ 'host' ] ) ) { if ( isset ( $ server [ 'port' ] ) && is_numeric ( $ server [ 'port' ] ) ) { $ this -> connect = ldap_connect ( $ server [ 'host' ] , $ server [ 'port' ] ) ; } else ... | This method create the LDAP link identifier on success and test the connection . |
53,373 | public function search ( $ server , $ filter , $ attributes = [ ] ) { return ldap_search ( $ this -> connect , $ server [ 'dn' ] , $ filter , $ attributes ) ; } | This method search something in LDAP directory using a filter . |
53,374 | public function getEntries ( $ search ) { $ entries = ldap_get_entries ( $ this -> connect , $ search ) ; array_walk_recursive ( $ entries , function ( & $ item ) { if ( ! mb_detect_encoding ( $ item , 'utf-8' , true ) ) { $ item = utf8_encode ( $ item ) ; } } ) ; return $ entries ; } | This method reads the entries of a LDAP search . |
53,375 | public function exists ( $ name , $ data ) { $ servers = isset ( $ this -> config [ 'servers' ] ) ? $ this -> config [ 'servers' ] : null ; if ( ( ! $ name || ( $ name && $ name !== $ data [ 'name' ] ) ) && isset ( $ data [ 'name' ] ) && isset ( $ servers [ $ data [ 'name' ] ] ) ) { return true ; } } | Test if a given server name exist in LDAP configuration . |
53,376 | public function deleteIfReplace ( $ name , $ data ) { if ( $ name && isset ( $ data [ 'name' ] ) && $ name !== $ data [ 'name' ] ) { $ this -> ldapUserRepo -> updateUsersByServerName ( $ name , $ data [ 'name' ] ) ; $ this -> deleteServer ( $ name ) ; } } | Delete a server configuration if the newest one replace it . |
53,377 | public function deleteServer ( $ name ) { if ( isset ( $ this -> config [ 'servers' ] ) && isset ( $ this -> config [ 'servers' ] [ $ name ] ) ) { unset ( $ this -> config [ 'servers' ] [ $ name ] ) ; $ this -> ldapUserRepo -> deleteUsersByServerName ( $ name ) ; return $ this -> saveConfig ( ) ; } } | Delete a server configuration . |
53,378 | public function saveSettings ( $ settings ) { if ( isset ( $ settings [ 'name' ] ) && isset ( $ this -> config [ 'servers' ] [ $ settings [ 'name' ] ] ) ) { return $ this -> saveConfig ( array_merge ( $ this -> config [ 'servers' ] [ $ settings [ 'name' ] ] , $ settings ) ) ; } } | Save the LDAP mapping settings . |
53,379 | public function saveConfig ( $ server = null ) { if ( is_array ( $ server ) && isset ( $ server [ 'name' ] ) ) { if ( ! isset ( $ server [ 'objectClass' ] ) ) { $ server = $ this -> setDefaultServerUserObject ( $ server ) ; } $ this -> config [ 'servers' ] [ $ server [ 'name' ] ] = $ server ; } return file_put_contents... | Save the LDAP configuration in a . yml file . |
53,380 | public function getClasses ( $ server ) { $ classes = [ ] ; if ( $ search = $ this -> search ( $ server , '(&(objectClass=*))' , [ 'objectclass' ] ) ) { $ entries = $ this -> getEntries ( $ search ) ; foreach ( $ entries as $ objectClass ) { if ( isset ( $ objectClass [ 'objectclass' ] ) ) { unset ( $ objectClass [ 'ob... | Get LDAP opbject classes . |
53,381 | public function getServers ( ) { $ servers = [ ] ; if ( isset ( $ this -> config [ 'servers' ] ) && is_array ( $ this -> config [ 'servers' ] ) ) { foreach ( $ this -> config [ 'servers' ] as $ server ) { $ servers [ ] = $ server [ 'name' ] ; } } return $ servers ; } | Return a list of available servers . |
53,382 | public function getActiveServers ( ) { $ activeServers = [ ] ; if ( isset ( $ this -> config [ 'servers' ] ) && is_array ( $ this -> config [ 'servers' ] ) ) { foreach ( $ this -> config [ 'servers' ] as $ server ) { if ( isset ( $ server [ 'active' ] ) && isset ( $ server [ 'objectClass' ] ) && $ server [ 'active' ] )... | Return a list of active servers . |
53,383 | private function parseYml ( ) { if ( ! file_exists ( $ this -> path ) ) { touch ( $ this -> path ) ; } return $ this -> yml -> parse ( file_get_contents ( $ this -> path ) ) ; } | Parse . yml file into LDAP configuration array . |
53,384 | public function authenticate ( Request $ request , $ serverName ) { $ server = $ this -> get ( $ serverName ) ; $ username = $ request -> get ( '_username' ) ; $ password = $ request -> get ( '_password' ) ; if ( ! empty ( $ username ) && ! empty ( $ password ) && $ this -> connect ( $ server , $ this -> prepareUsernam... | Authenticate ldap user . |
53,385 | public function check ( string $ type , string $ context ) : bool { $ dataSource = $ this -> dataSourceRepository -> findOneBy ( [ 'name' => $ type ] ) ; if ( ! $ dataSource ) { return false ; } if ( ! in_array ( $ context , $ dataSource -> getContext ( ) ) ) { return false ; } return true ; } | Checks if a data source exists and is available for the given context . |
53,386 | public function load ( string $ type , string $ context , $ contextId = null , array $ options = null ) { $ user = null ; if ( $ this -> tokenStorage -> getToken ( ) -> getUser ( ) instanceof User ) { $ user = $ this -> tokenStorage -> getToken ( ) -> getUser ( ) ; } $ workspace = null ; if ( DataSource :: CONTEXT_WORK... | Loads data from a data source . |
53,387 | public function addChild ( self $ resourceNode ) { if ( ! $ this -> children -> contains ( $ resourceNode ) ) { $ this -> children -> add ( $ resourceNode ) ; } } | Add a child resource node . |
53,388 | public static function getList ( ) { return [ static :: CHOICE , static :: CLOZE , static :: GRAPHIC , static :: MATCH , static :: PAIR , static :: SET , static :: WORDS , static :: OPEN , static :: SELECTION , static :: GRID , static :: CONTENT , static :: ORDERING , static :: BOOLEAN , ] ; } | Get the list of managed item types . |
53,389 | public function serialize ( Lesson $ lesson , array $ options = [ ] ) { $ firstChapter = $ this -> chapterRepository -> getFirstChapter ( $ lesson ) ; $ serialized = [ 'id' => $ lesson -> getUuid ( ) , 'title' => $ lesson -> getResourceNode ( ) -> getName ( ) , 'firstChapterId' => $ firstChapter ? $ firstChapter -> get... | Serializes a Lesson entity for the JSON api . |
53,390 | public function search ( $ class , array $ finderParams = [ ] , array $ serializerOptions = [ ] ) { $ queryParams = self :: parseQueryParams ( $ finderParams ) ; $ page = $ queryParams [ 'page' ] ; $ limit = $ queryParams [ 'limit' ] ; $ filters = $ queryParams [ 'filters' ] ; $ allFilters = $ queryParams [ 'allFilters... | Builds and fires the query for a given class . The result will be serialized afterwards . |
53,391 | public function fetch ( $ class , array $ filters = [ ] , array $ sortBy = null , $ page = 0 , $ limit = - 1 , $ count = false ) { try { return $ this -> get ( $ class ) -> find ( $ filters , $ sortBy , $ page , $ limit , $ count ) ; } catch ( FinderException $ e ) { $ data = $ this -> om -> getRepository ( $ class ) -... | Builds and fires the query for a given class . There will be no serialization here . |
53,392 | public static function parseQueryParams ( array $ finderParams = [ ] ) { $ filters = isset ( $ finderParams [ 'filters' ] ) ? self :: parseFilters ( $ finderParams [ 'filters' ] ) : [ ] ; $ sortBy = isset ( $ finderParams [ 'sortBy' ] ) ? self :: parseSortBy ( $ finderParams [ 'sortBy' ] ) : null ; $ page = isset ( $ f... | Parses query params to their appropriate filter values . |
53,393 | public function findAllAvailable ( array $ enabledPlugins , $ context = null ) { $ query = $ this -> createQueryBuilder ( 'ds' ) -> leftJoin ( 'ds.plugin' , 'p' ) -> where ( 'CONCAT(p.vendorName, p.bundleName) IN (:plugins)' ) -> setParameter ( 'plugins' , $ enabledPlugins ) ; if ( $ context ) { $ query -> andWhere ( '... | Finds all available data sources in the platform . It only grabs sources from enabled plugins . |
53,394 | public function onSerialize ( DecorateResourceNodeEvent $ event ) { $ options = $ event -> getOptions ( ) ; if ( ! in_array ( Options :: SKIP_RESOURCE_NOTIFICATION , $ options ) ) { $ node = $ event -> getResourceNode ( ) ; $ user = $ this -> tokenStorage -> getToken ( ) -> getUser ( ) ; $ followResource = $ user !== '... | Add notifications option to serialized resource node when requested through API . |
53,395 | public function serialize ( $ object , array $ options = [ ] ) { return $ this -> mapEntityToObject ( $ this -> getSerializableProperties ( $ object ) , $ object , new \ StdClass ( ) ) ; } | Default serialize method . |
53,396 | public function deserialize ( $ data , $ object , array $ options = [ ] ) { $ properties = $ this -> getSerializableProperties ( $ object , [ self :: INCLUDE_MANY_TO_ONE ] ) ; $ data = json_decode ( json_encode ( $ data ) ) ; return $ this -> mapObjectToEntity ( $ properties , $ this -> resolveData ( $ properties , $ d... | Default deserialize method . |
53,397 | protected function mapObjectToEntity ( array $ mapping , \ stdClass $ data , $ entity ) { foreach ( $ mapping as $ dataProperty => $ map ) { if ( property_exists ( $ data , $ dataProperty ) ) { if ( is_string ( $ map ) || is_object ( $ map ) || is_int ( $ map ) ) { try { $ setter = $ this -> getEntitySetter ( $ entity ... | Maps raw object data into entity properties . |
53,398 | protected function mapEntityToObject ( array $ mapping , $ entity , \ stdClass $ data ) { foreach ( $ mapping as $ dataProperty => $ map ) { $ value = null ; if ( is_string ( $ map ) ) { $ getter = $ this -> getEntityGetter ( $ entity , $ map ) ; $ value = call_user_func ( [ $ entity , $ getter ] ) ; } elseif ( is_call... | Maps entity properties into raw object . |
53,399 | private function getEntityGetter ( $ entity , $ property ) { $ getter = null ; $ prefixes = [ 'get' , 'is' , 'has' , '' ] ; foreach ( $ prefixes as $ prefix ) { $ test = $ prefix . ucfirst ( $ property ) ; if ( method_exists ( $ entity , $ test ) ) { $ getter = $ test ; break ; } } if ( null === $ getter ) { throw new ... | Gets the correct getter name for an entity property . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.