mirror of
				https://github.com/shlinkio/shlink.git
				synced 2025-02-25 18:45:27 -06:00 
			
		
		
		
	Some more refactorings
This commit is contained in:
		@@ -3,7 +3,7 @@ LABEL maintainer="Alejandro Celaya <alejandro@alejandrocelaya.com>"
 | 
			
		||||
 | 
			
		||||
ARG SHLINK_VERSION=1.18.1
 | 
			
		||||
ENV SHLINK_VERSION ${SHLINK_VERSION}
 | 
			
		||||
ENV SWOOLE_VERSION 4.3.3
 | 
			
		||||
ENV SWOOLE_VERSION 4.4.8
 | 
			
		||||
ENV COMPOSER_VERSION 1.9.0
 | 
			
		||||
 | 
			
		||||
WORKDIR /etc/shlink
 | 
			
		||||
 
 | 
			
		||||
@@ -10,5 +10,5 @@ echo 'Starting server...'
 | 
			
		||||
vendor/bin/zend-expressive-swoole start -d
 | 
			
		||||
sleep 2
 | 
			
		||||
 | 
			
		||||
vendor/bin/phpunit --order-by=random -c phpunit-api.xml --testdox --colors=always
 | 
			
		||||
APP_ENV=test DB_DRIVER=mysql vendor/bin/phpunit --order-by=random -c phpunit-api.xml --testdox --colors=always
 | 
			
		||||
vendor/bin/zend-expressive-swoole stop
 | 
			
		||||
 
 | 
			
		||||
@@ -34,7 +34,7 @@
 | 
			
		||||
        "phly/phly-event-dispatcher": "^1.0",
 | 
			
		||||
        "predis/predis": "^1.1",
 | 
			
		||||
        "pugx/shortid-php": "^0.5",
 | 
			
		||||
        "shlinkio/shlink-common": "^2.1",
 | 
			
		||||
        "shlinkio/shlink-common": "^2.2",
 | 
			
		||||
        "shlinkio/shlink-event-dispatcher": "^1.0",
 | 
			
		||||
        "shlinkio/shlink-installer": "^2.1",
 | 
			
		||||
        "shlinkio/shlink-ip-geolocation": "^1.1",
 | 
			
		||||
 
 | 
			
		||||
@@ -4,6 +4,7 @@ MAINTAINER Alejandro Celaya <alejandro@alejandrocelaya.com>
 | 
			
		||||
ENV APCU_VERSION 5.1.16
 | 
			
		||||
ENV APCU_BC_VERSION 1.0.4
 | 
			
		||||
ENV INOTIFY_VERSION 2.0.0
 | 
			
		||||
ENV SWOOLE_VERSION 4.4.8
 | 
			
		||||
 | 
			
		||||
RUN apk update
 | 
			
		||||
 | 
			
		||||
@@ -66,7 +67,7 @@ RUN rm /tmp/inotify.tar.gz
 | 
			
		||||
# Install swoole
 | 
			
		||||
# First line fixes an error when installing pecl extensions. Found in https://github.com/docker-library/php/issues/233
 | 
			
		||||
RUN apk add --no-cache --virtual .phpize-deps $PHPIZE_DEPS && \
 | 
			
		||||
    pecl install swoole && \
 | 
			
		||||
    pecl install swoole-${SWOOLE_VERSION} && \
 | 
			
		||||
    docker-php-ext-enable swoole && \
 | 
			
		||||
    apk del .phpize-deps
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -34,6 +34,7 @@ services:
 | 
			
		||||
            dockerfile: ./data/infra/swoole.Dockerfile
 | 
			
		||||
        ports:
 | 
			
		||||
            - "8080:8080"
 | 
			
		||||
            - "9001:9001"
 | 
			
		||||
        volumes:
 | 
			
		||||
            - ./:/home/shlink
 | 
			
		||||
        links:
 | 
			
		||||
 
 | 
			
		||||
@@ -60,7 +60,6 @@ $builder->createManyToMany('tags', Entity\Tag::class)
 | 
			
		||||
        ->setJoinTable('short_urls_in_tags')
 | 
			
		||||
        ->addInverseJoinColumn('tag_id', 'id', true, false, 'CASCADE')
 | 
			
		||||
        ->addJoinColumn('short_url_id', 'id', true, false, 'CASCADE')
 | 
			
		||||
        ->cascadePersist()
 | 
			
		||||
        ->build();
 | 
			
		||||
 | 
			
		||||
$builder->createManyToOne('domain', Entity\Domain::class)
 | 
			
		||||
 
 | 
			
		||||
@@ -8,6 +8,7 @@ use Doctrine\Common\Collections;
 | 
			
		||||
use Doctrine\ORM\EntityManagerInterface;
 | 
			
		||||
use Shlinkio\Shlink\Core\Entity\Tag;
 | 
			
		||||
 | 
			
		||||
use function Functional\map;
 | 
			
		||||
use function str_replace;
 | 
			
		||||
use function strtolower;
 | 
			
		||||
use function trim;
 | 
			
		||||
@@ -21,18 +22,13 @@ trait TagManagerTrait
 | 
			
		||||
     */
 | 
			
		||||
    private function tagNamesToEntities(EntityManagerInterface $em, array $tags): Collections\Collection
 | 
			
		||||
    {
 | 
			
		||||
        $entities = [];
 | 
			
		||||
        foreach ($tags as $tagName) {
 | 
			
		||||
        $entities = map($tags, function (string $tagName) use ($em): Tag {
 | 
			
		||||
            $tagName = $this->normalizeTagName($tagName);
 | 
			
		||||
            $tag = $em->getRepository(Tag::class)->findOneBy(['name' => $tagName]) ?? new Tag($tagName);
 | 
			
		||||
            $em->persist($tag);
 | 
			
		||||
 | 
			
		||||
//            if (! $tag) {
 | 
			
		||||
//                $tag = ;
 | 
			
		||||
//                $em->persist($tag);
 | 
			
		||||
//            }
 | 
			
		||||
 | 
			
		||||
            $entities[] = $tag;
 | 
			
		||||
        }
 | 
			
		||||
            return $tag;
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        return new Collections\ArrayCollection($entities);
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -50,10 +50,10 @@ class CreateShortUrlActionTest extends ApiTestCase
 | 
			
		||||
    /** @test */
 | 
			
		||||
    public function createsNewShortUrlWithTags(): void
 | 
			
		||||
    {
 | 
			
		||||
        [$statusCode, $payload] = $this->createShortUrl(['tags' => ['foo', 'bar', 'baz']]);
 | 
			
		||||
        [$statusCode, ['tags' => $tags]] = $this->createShortUrl(['tags' => ['foo', 'bar', 'baz']]);
 | 
			
		||||
 | 
			
		||||
        $this->assertEquals(self::STATUS_OK, $statusCode);
 | 
			
		||||
        $this->assertEquals(['foo', 'bar', 'baz'], $payload['tags']);
 | 
			
		||||
        $this->assertEquals(['foo', 'bar', 'baz'], $tags);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user