Xpressengine\Translation\LangData::each PHP Method

each() public method

public each ( Closure $closure ) : void
$closure Closure 반복자
return void
    public function each(\Closure $closure)
    {
        foreach ($this->data as $item => $locales) {
            foreach ($locales as $locale => $value) {
                $closure($item, $locale, $value);
            }
        }
    }

Usage Example

Ejemplo n.º 1
0
 public function testLangData()
 {
     $data = ['previous' => ['ko' => '이전', 'en' => 'Prev'], 'next' => ['ko' => '다음', 'en' => 'Next'], 'week' => ['mon' => ['ko' => '월', 'en' => 'monday'], 'tue' => ['ko' => '화', 'en' => 'tueseday']]];
     $expectedData = ['previous' => ['ko' => '이전', 'en' => 'Prev'], 'next' => ['ko' => '다음', 'en' => 'Next'], 'week.mon' => ['ko' => '월', 'en' => 'monday'], 'week.tue' => ['ko' => '화', 'en' => 'tueseday']];
     $retrievedData = [];
     $langData = new LangData();
     $langData->setData($data);
     $langData->each(function ($item, $locale, $value) use(&$retrievedData) {
         $retrievedData[$item][$locale] = $value;
     });
     $this->assertSame($expectedData, $retrievedData);
 }
All Usage Examples Of Xpressengine\Translation\LangData::each