Created
August 1, 2018 09:58
-
-
Save BerezhniyDmitro/267f4276391d1fdb08122fad27bef757 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use App\Libraries\Doctrine; | |
use App\Models\Page\Builder\ServicePageBuilder; | |
use App\Models\Page\PageManager; | |
use App\Models\Page\ServicePage\Entity\ServicePage; | |
use App\Models\Page\ServicePage\Entity\ServicePageSeo; | |
use App\Models\Page\ServicePage\Entity\ServicePageSitemap; | |
use App\Models\Page\ServicePage\Entity\ServicePageSocial; | |
use App\Models\Page\ServicePage\Repository\ServicePageRepository; | |
use App\Models\Page\ServicePage\Repository\SitemapRepository; | |
use App\Models\Page\ServicePage\Validation\ServicePageValidateService; | |
use App\Models\Promotion\Services\PromotionDataServices; | |
use Components\Core\Container; | |
/** | |
* Class Test | |
*/ | |
class Test extends CI_Controller | |
{ | |
/** | |
* Test constructor. | |
*/ | |
public function __construct() | |
{ | |
parent::__construct(); | |
} | |
/** | |
* Метод проверяет доступ к странице | |
* | |
* @param $key | |
*/ | |
private function _check_access($key) | |
{ | |
if ($key != 'HO0NuWY0BnqHUDPjylSQ') { | |
show_404(__METHOD__ . $this->general_model->info_404()); | |
} | |
} | |
/** | |
* Метод для теста | |
* | |
* @param string $key ключ доступа | |
*/ | |
public function testing($key) | |
{ | |
$this->_check_access($key); | |
$em = Container::instance()->container->get(Doctrine::class)->em; | |
// $seo = $em->getRepository(ServicePageSitemap::class)->find(40); | |
// var_dump($seo); die; //FIXME | |
// $em->clear(); | |
// var_dump(123); die; //FIXME | |
// $page = $em->getRepository(ServicePage::class)->find(84); | |
// var_dump($page); die; //FIXME | |
$data = [ | |
'main_id' => 5, | |
'main_current_language_id' => 3, | |
'main_name_page' => 'Тестовая', | |
'main_is_expanded' => 1, | |
'main_name_page_top' => 'Тест', | |
'main_name_page_bottom' => 'Тест', | |
'main_short_description_page' => 'Тест тест', | |
'main_description_main' => 'Описание', | |
'main_parent_service' => null, | |
'main_segment_url' => 'test', | |
'main_icon' => 'i-hide', | |
'main_selected_categories' => [1,2], | |
'seo_title' => 'SEO Title Doctrine', | |
'seo_description' => 'Seo Descr from Doctrine', | |
'seo_keywords' => '', | |
'seo_robots' => 'noindex', | |
'seo_canonical' => '', | |
'seo_breadcrumbs' => '', | |
'social_title' => '', | |
'social_is_used_title_from_seo' => 1, | |
'social_description' => '', | |
'social_is_used_description_from_seo' => 1, | |
'social_image' => '', | |
'social_og_type' => 'яыаввыавыа', | |
'social_twitter_card' => '', | |
'social_required' => 0, | |
'sitemap_html' => 1, | |
'sitemap_xml' => 1, | |
'sitemap_priority' => 0.5, | |
'sitemap_change_frequency' => 'monthly', | |
'sitemap_required' => 1, | |
]; | |
$page = new ServicePage(); | |
$page->changeId($data['main_id']); | |
$page->changeTitle($data['main_name_page']); | |
$page->changeUrl($data['main_segment_url']); | |
$page->changeShortDescription($data['main_short_description_page']); | |
$page->changeIsVisible($data['main_is_visible']); | |
$sitemap = new ServicePageSitemap( | |
$data['sitemap_xml'], | |
$data['sitemap_html'], | |
$data['sitemap_priority'], | |
$data['sitemap_change_frequency'] | |
); | |
$page->changeSitemap($sitemap); | |
$em->merge($page); | |
$em->flush(); | |
} | |
/** | |
* Метод для отображения логов битрикса | |
* | |
* @param string $key ключ доступа | |
*/ | |
public function bitrix_api_test($key) | |
{ | |
$this->_check_access($key); | |
$date = new DateTime(); | |
$filename = sprintf('%s_bitrix.log', $date->format('d-m-Y')); | |
$dir_path = 'logs/bitrix24'; | |
$path = sprintf('%s/%s', $dir_path, $filename); | |
$file = new SplFileObject($path, 'r'); | |
while (!$file->eof()) { | |
echo '<pre>'; | |
print_r($file->fgets()); | |
echo '</pre>'; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment