Commit fe9c81e1 authored by Pawel G's avatar Pawel G
Browse files

Clean up some

parent 7066cd20
...@@ -41,7 +41,7 @@ services: ...@@ -41,7 +41,7 @@ services:
public: false public: false
simple_sitemap.entity_url_generator: simple_sitemap.entity_url_generator:
class: Drupal\simple_sitemap\Batch\EntityUrlGenerator class: Drupal\simple_sitemap\Batch\Generator\EntityUrlGenerator
public: true public: true
arguments: arguments:
- '@simple_sitemap.generator' - '@simple_sitemap.generator'
...@@ -53,7 +53,7 @@ services: ...@@ -53,7 +53,7 @@ services:
- '@simple_sitemap.entity_helper' - '@simple_sitemap.entity_helper'
simple_sitemap.custom_url_generator: simple_sitemap.custom_url_generator:
class: Drupal\simple_sitemap\Batch\CustomUrlGenerator class: Drupal\simple_sitemap\Batch\Generator\CustomUrlGenerator
public: true public: true
arguments: arguments:
- '@simple_sitemap.generator' - '@simple_sitemap.generator'
...@@ -65,7 +65,7 @@ services: ...@@ -65,7 +65,7 @@ services:
- '@simple_sitemap.entity_helper' - '@simple_sitemap.entity_helper'
simple_sitemap.arbitrary_url_generator: simple_sitemap.arbitrary_url_generator:
class: Drupal\simple_sitemap\Batch\ArbitraryUrlGenerator class: Drupal\simple_sitemap\Batch\Generator\ArbitraryUrlGenerator
public: true public: true
arguments: arguments:
- '@simple_sitemap.generator' - '@simple_sitemap.generator'
......
...@@ -115,16 +115,6 @@ class Batch { ...@@ -115,16 +115,6 @@ class Batch {
]; ];
} }
/**
* Batch callback function which generates urls to entity paths.
*
* @param array $entity_info
* @param array $batch_info
* @param array &$context
*
* @see https://api.drupal.org/api/drupal/core!includes!form.inc/group/batch/8
*/
/** /**
* Batch callback function which generates URLs. * Batch callback function which generates URLs.
* *
......
<?php <?php
namespace Drupal\simple_sitemap\Batch; namespace Drupal\simple_sitemap\Batch\Generator;
/** /**
* Class ArbitraryUrlGenerator * Class ArbitraryUrlGenerator
* @package Drupal\simple_sitemap\Batch * @package Drupal\simple_sitemap\Batch\Generator
*/ */
class ArbitraryUrlGenerator extends UrlGeneratorBase implements UrlGeneratorInterface { class ArbitraryUrlGenerator extends UrlGeneratorBase implements UrlGeneratorInterface {
...@@ -16,8 +16,7 @@ class ArbitraryUrlGenerator extends UrlGeneratorBase implements UrlGeneratorInte ...@@ -16,8 +16,7 @@ class ArbitraryUrlGenerator extends UrlGeneratorBase implements UrlGeneratorInte
* @see \hook_simple_sitemap_arbitrary_links_alter() * @see \hook_simple_sitemap_arbitrary_links_alter()
*/ */
public function generate($arbitrary_paths) { public function generate($arbitrary_paths) {
foreach ($this->getBatchIterationElements(array_values($arbitrary_paths)) as $i => $path_data) {
foreach ($this->getBatchIterationElements($arbitrary_paths) as $i => $path_data) {
$this->setCurrentId($i); $this->setCurrentId($i);
$this->addUrl($path_data); $this->addUrl($path_data);
} }
......
<?php <?php
namespace Drupal\simple_sitemap\Batch; namespace Drupal\simple_sitemap\Batch\Generator;
use Drupal\Core\Url; use Drupal\Core\Url;
/** /**
* Class BatchUrlGenerator * Class CustomUrlGenerator
* @package Drupal\simple_sitemap\Batch * @package Drupal\simple_sitemap\Batch\Generator
*
* @todo Add image support
*/ */
class CustomUrlGenerator extends UrlGeneratorBase implements UrlGeneratorInterface { class CustomUrlGenerator extends UrlGeneratorBase implements UrlGeneratorInterface {
......
<?php <?php
namespace Drupal\simple_sitemap\Batch; namespace Drupal\simple_sitemap\Batch\Generator;
/** /**
* Class BatchUrlGenerator * Class EntityUrlGenerator
* @package Drupal\simple_sitemap\Batch * @package Drupal\simple_sitemap\Batch\Generator
*/ */
class EntityUrlGenerator extends UrlGeneratorBase implements UrlGeneratorInterface { class EntityUrlGenerator extends UrlGeneratorBase implements UrlGeneratorInterface {
...@@ -73,19 +73,6 @@ class EntityUrlGenerator extends UrlGeneratorBase implements UrlGeneratorInterfa ...@@ -73,19 +73,6 @@ class EntityUrlGenerator extends UrlGeneratorBase implements UrlGeneratorInterfa
$this->processSegment(); $this->processSegment();
} }
/**
* @param $entity_type_name
* @param $entity_id
* @return array
*/
protected function getImages($entity_type_name, $entity_id) {
$images = [];
foreach ($this->entityHelper->getEntityImageUrls($entity_type_name, $entity_id) as $Url) {
$images[]['path'] = $Url;
}
return $images;
}
/** /**
* @param array $entity_info * @param array $entity_info
* @return \Drupal\Core\Entity\EntityInterface[] * @return \Drupal\Core\Entity\EntityInterface[]
......
<?php <?php
namespace Drupal\simple_sitemap\Batch; namespace Drupal\simple_sitemap\Batch\Generator;
use Drupal\Component\Utility\Html; use Drupal\Component\Utility\Html;
use Drupal\Core\Entity\ContentEntityBase; use Drupal\Core\Entity\ContentEntityBase;
...@@ -16,8 +16,8 @@ use Drupal\Core\Entity\EntityTypeManagerInterface; ...@@ -16,8 +16,8 @@ use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Path\PathValidator; use Drupal\Core\Path\PathValidator;
/** /**
* Class BatchUrlGenerator * Class UrlGeneratorBase
* @package Drupal\simple_sitemap\Batch * @package Drupal\simple_sitemap\Batch\Generator
*/ */
class UrlGeneratorBase { class UrlGeneratorBase {
...@@ -303,7 +303,6 @@ class UrlGeneratorBase { ...@@ -303,7 +303,6 @@ class UrlGeneratorBase {
* @return array * @return array
*/ */
protected function getBatchIterationElements(array $elements) { protected function getBatchIterationElements(array $elements) {
if ($this->needsInitialization()) { if ($this->needsInitialization()) {
$this->initializeBatch(count($elements)); $this->initializeBatch(count($elements));
} }
...@@ -314,4 +313,17 @@ class UrlGeneratorBase { ...@@ -314,4 +313,17 @@ class UrlGeneratorBase {
return $elements; return $elements;
} }
/**
* @param $entity_type_name
* @param $entity_id
* @return array
*/
protected function getImages($entity_type_name, $entity_id) {
$images = [];
foreach ($this->entityHelper->getEntityImageUrls($entity_type_name, $entity_id) as $Url) {
$images[]['path'] = $Url;
}
return $images;
}
} }
<?php <?php
namespace Drupal\simple_sitemap\Batch; namespace Drupal\simple_sitemap\Batch\Generator;
/** /**
* Interface UrlGeneratorInterface * Interface UrlGeneratorInterface
* @package Drupal\simple_sitemap\Batch * @package Drupal\simple_sitemap\Batch\Generator
*/ */
interface UrlGeneratorInterface { interface UrlGeneratorInterface {
......
...@@ -7,6 +7,8 @@ use Drupal\Core\Form\FormStateInterface; ...@@ -7,6 +7,8 @@ use Drupal\Core\Form\FormStateInterface;
/** /**
* Class SimplesitemapCustomLinksForm * Class SimplesitemapCustomLinksForm
* @package Drupal\simple_sitemap\Form * @package Drupal\simple_sitemap\Form
*
* @todo Add image support
*/ */
class SimplesitemapCustomLinksForm extends SimplesitemapFormBase { class SimplesitemapCustomLinksForm extends SimplesitemapFormBase {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment