Code Duplication    Length = 20-20 lines in 2 locations

Controller/JqadmController.php 1 location

@@ 168-187 (lines=20) @@
165
	 * @param string $lang ISO language code, e.g. "en" or "en_GB"
166
	 * @return \Aimeos\MShop\Context\Item\Iface Modified context object
167
	 */
168
	protected function setLocale( \Aimeos\MShop\Context\Item\Iface $context, $sitecode = 'default', $lang = null )
169
	{
170
		$localeManager = \Aimeos\MShop\Factory::createManager( $context, 'locale' );
171
172
		try
173
		{
174
			$localeItem = $localeManager->bootstrap( $sitecode, '', '', false );
175
			$localeItem->setLanguageId( null );
176
			$localeItem->setCurrencyId( null );
177
		}
178
		catch( \Aimeos\MShop\Locale\Exception $e )
179
		{
180
			$localeItem = $localeManager->createItem();
181
		}
182
183
		$context->setLocale( $localeItem );
184
		$context->setI18n( $this->get( 'aimeos_i18n' )->get( array( $lang ) ) );
185
186
		return $context;
187
	}
188
}
189

Controller/JsonadmController.php 1 location

@@ 204-223 (lines=20) @@
201
	 * @param string $lang ISO language code, e.g. "en" or "en_GB"
202
	 * @return \Aimeos\MShop\Context\Item\Iface Modified context object
203
	 */
204
	protected function setLocale( \Aimeos\MShop\Context\Item\Iface $context, $sitecode, $lang )
205
	{
206
		$localeManager = \Aimeos\MShop\Factory::createManager( $context, 'locale' );
207
208
		try
209
		{
210
			$localeItem = $localeManager->bootstrap( $sitecode, '', '', false );
211
			$localeItem->setLanguageId( null );
212
			$localeItem->setCurrencyId( null );
213
		}
214
		catch( \Aimeos\MShop\Locale\Exception $e )
215
		{
216
			$localeItem = $localeManager->createItem();
217
		}
218
219
		$context->setLocale( $localeItem );
220
		$context->setI18n( $this->get('aimeos_i18n')->get( array( $lang ) ) );
221
222
		return $context;
223
	}
224
}
225