示例#1
0
 /** @test */
 public function itSplicesWithCallbacksUsingLimits()
 {
     $iterations = 0;
     $results = Arr::spliceWhere($this->arr, function ($val, $key) use(&$iterations) {
         return TRUE;
     }, 3);
     $this->assertCount(3, $results);
 }
示例#2
0
 /**
  * This is a helper method for other classes, not necessarily part of the EmailService API.
  *
  * @return array
  */
 public function getAvailableTemplateKeys()
 {
     $exts = array();
     $keys = array();
     $cicbaseSettings = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_SETTINGS, 'cicbase', 'default');
     if (isset($cicbaseSettings['emailTemplateOverrides']['extensions'])) {
         $exts = $cicbaseSettings['emailTemplateOverrides']['extensions'];
         if (!is_array($exts) || !count($exts)) {
             return array();
         }
     }
     $whereAllowed = function ($templateDefinition, $templateKey) {
         return !isset($templateDefinition['noOverride']) || !$templateDefinition['noOverride'];
     };
     $keyTrimmer = function ($key) {
         return rtrim($key, '.');
     };
     foreach ($exts as $extKey) {
         $extConf = $this->getTyposcriptForExtension($extKey);
         if (!is_array($extConf)) {
             continue;
         }
         $extSettings = $extConf["settings"];
         if (!is_array($extSettings)) {
             continue;
         }
         Arr::walkKeysRecursive($extSettings, $keyTrimmer);
         if (!isset($extSettings['email']['templates'])) {
             continue;
         }
         $templates = $extSettings['email']['templates'];
         $allowedTemplates = Arr::spliceWhere($templates, $whereAllowed);
         $keys[$extKey] = array_keys($allowedTemplates);
     }
     $this->emailTemplateRepository->filterOutExistingTemplateKeys($keys);
     return $keys;
 }