Code Monkey home page Code Monkey logo

kayuewordpressbundle's Introduction

KayueWordpressBundle

Improved version of the original WordpressBundle. The biggest different is this new KayueWordpressBundle won't load the entire WordPress core, thus all the WordPress template funtions won't be available in your Symfony app. This is also the goal of the bundle; do everything in Symfony's way.

I started that bundle two years ago and the original repository grew somewhat chaotically, so I decided to start fresh with new repositories.

Build Status

Features

  • WordPress authentication (v1.0.0)
  • Custom table prefix (v1.0.1)
  • WordPress entities (v1.0.2)
  • Multisite support (v1.1.0)
  • Twig extension (v1.1.0)
  • WordPress style shortcode (v1.1.0)
  • Major code update. (v2.0.0)
  • Support Symfony 4, new cache configuration (v4.0.0)

Todo

  • Unit test (please help!)

Installation

Composer

composer require kayue/kayue-wordpress-bundle

Register the bundle

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new Kayue\WordpressBundle\KayueWordpressBundle(),
    );
    // ...
}

Configuration

Doctrine

This bundle requrie database connection. Make sure you have Doctrine configurated properly.

// app/config/parameters.yml

parameters:
    database_driver:   pdo_mysql
    database_host:     127.0.0.1
    database_port:     ~
    database_name:     my_wordpress_db
    database_user:     root
    database_password: pass

config.yml

The following configuration is optional.

kayue_wordpress:
    # Custom table prefix. Default is "wp_".
    table_prefix:   'wp_'

    # Doctrine connection to use. Default is 'default'.
    connection: 'default'

    # Specify Symfony cache pool
    orm:
        metadata_cache_pool: cache.system
        query_cache_pool: cache.app
        result_cache_pool: cache.app
    
    # The following configuration only needed only when you use WordPress authentication. 
    
    # Site URL must match *EXACTLY* with WordPress's setting. Can be found
    # on the Settings > General screen, there are field named "WordPress Address"
    site_url:       'http://localhost/wordpress'

    # Logged in key and salt. Can be found in the wp-config.php file.
    logged_in_key:  ':j$_=(:l@8Fku^U;MQ~#VOJXOZcVB_@u+t-NNYqmTH4na|)5Bhs1|tF1IA|>tz*E'
    logged_in_salt: ')A^CQ<R:1|^dK/Q;.QfP;U!=J=(_i6^s0f#2EIbGIgFN{,3U9H$q|o/sJfWF`NRM'

    # WordPress cookie path / domain settings.
    cookie_path:    '/'
    cookie_domain:  null

Usage

An example to obtain post content, author, comments and categories:

<?php
// path/to/controller.php

public function postAction($slug)
{
    $repo = $this->get('kayue_wordpress')->getManager()->getRepository('KayueWordpressBundle:Post');
    $post = $repo->findOneBy(array(
        'slug'   => 'hello-world',
        'type'   => 'post',
        'status' => 'publish',
    ));

    echo $post->getTitle() , "\n";
    echo $post->getUser()->getDisplayName() , "\n";
    echo $post->getContent() , "\n";

    foreach($post->getComments() as $comment) {
        echo $comment->getContent() . "\n";
    }

    foreach($post->getTaxonomies()->filter(function(Taxonomy $tax) {
        // Only return categories, not tags or anything else.
        return 'category' === $tax->getName();
    }) as $tax) {
        echo $tax->getTerm()->getName() . "\n";
    }

    // ...
}

Twig Extension

This bundle comes with the following Twig extensions.

Functions

  • wp_switch_blog - equivalent to WordPress's switch_to_blog() method.
  • wp_find_option_by - equivalent to WordPress's get_option() method.
  • wp_find_post_by - Get post by ID or slug.
  • wp_find_post_metas_by($post, $key) - equivalent to WordPress's get_post_meta() method.
  • wp_find_post_metas_by({'post': $post, 'key': $key}) - Same as above, accept array as argument.
  • wp_find_comments_by_post($post) - return all approved comments in a post.
  • wp_find_attachments_by_post($post)
  • wp_find_attachment_by_id($id)
  • wp_find_thumbnail($post) - alias of wp_find_featured_image_by_post
  • wp_find_featured_image - equivalent to WordPress's get_the_post_thumbnail method.
  • wp_get_attachment_url($post)
  • wp_get_post_format
  • wp_find_terms_by_post
  • wp_find_categories_by_post - equivalent to WordPress's get_categories() method.
  • wp_find_tags_by_post - equivalent to WordPress's get_tags() method.

Filters

  • wp_autop - Wrap paragraph with <p> tag. Needed for post formatting.
  • wp_texturize - Texturize. Needed for post formatting
  • wp_shortcode - equivalent to WordPress's do_shortcode() method.

To transform extra content like video links or social network links, you can use the Essence Bundle

Multisite

Multisite is a feature of WordPress that allows multiple virtual sites to share a single WordPress installation. In this bundle, each blog (site) has its own entity manager. You need to use blog manager to retrive the blog and then the entity manager.

The following example shows you how to display the latest 10 posts in blog 2.

<?php

public function firstPostAction()
{
    // Method 1: Switch current blog's id. Similar to WordPress's `switch_to_blog()` method.
    // Changing the current blog ID will affect Twig extensions too.
    $blogManager = $this->get('kayue_wordpress')->getManager();
    $blogManager->setCurrentBlogId(2);
    $this->getRepository('KayueWordpressBundle:Post')->findOnePostById(1);

    // Method 2: Use entity manager if you don't want to switch the entire blog.
    // This won't change the current blog ID.
    $blogId = 3;
    $anotherBlog = $this->get('kayue_wordpress')->getManager($blogId);
    $posts = $anotherBlog->getRepository('KayueWordpressBundle:Post')->findOneById(1);
}

WordPress Authentication

This bundle allow you to create a WordPress login form in Symfony. All you have to do is to configure the WordPress firewall in your security.yml.

The following example demonstrates how to turn AcmeDemoBundle's login form into a WordPress login form.

security:
    encoders:
        # Add the WordPress password encoder
        Kayue\WordpressBundle\Entity\User:
            id: kayue_wordpress.security.encoder.phpass

    providers:
        # Add the WordPress user provider
        wordpress:
            entity: { class: Kayue\WordpressBundle\Entity\User, property: username }

    firewalls:
        login:
            pattern:  ^/demo/secured/login$
            security: false
        secured_area:
            pattern:    ^/demo/secured/
            # Add the WordPress firewall. Allow you to read WordPress's login state in Symfony app.
            kayue_wordpress: ~
            # Optional. Symfony's default form login works for WordPress user too.
            form_login:
                 check_path: /demo/secured/login_check
                 login_path: /demo/secured/login
                 default_target_path: /demo/secured/hello/world
            # Optional. Use this to logout.
            logout:
                path:   /demo/secured/logout
                target: /demo/secured/login
            # ...

Shortcode

WordpressBundle support WordPress style shortcode. At the moment the bundle only come with the [caption] and [gallery] shortcode. Pull request is welcome.

To create new shortcode, you need to

  1. extends ShortcodeInterface
  2. tag it with kayue_wordpress.shortcode
<?php

use Kayue\WordpressBundle\Wordpress\Shortcode\ShortcodeInterface;

class GalleryShortcode implements ShortcodeInterface
{
    public function getName()
    {
        return 'gallery';
    }

    public function($attr, $content = null)
    {
        // do your things...

        return "<p>Return HTML</p>";
    }
}
}
services:
    acme_demo_bundle.wordpress.shortcode.gallery:
        class: Acme\DemoBundle\Wordpress\Shortcode\GalleryShortcode
        tags:
            - { name: kayue_wordpress.shortcode }

kayuewordpressbundle's People

Contributors

benglass avatar diegomarangoni avatar drakenya avatar ebernardf6 avatar foopang avatar garethchidgey avatar gromnan avatar jsibbiso avatar kayue avatar kornelkrupa avatar nek- avatar peterlozano avatar tom10271 avatar umpirsky avatar warrenlee avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

kayuewordpressbundle's Issues

Difficulty linking directly to post

After digging around a bit, looking for a simple way to link directly to a blog post, I've found that the only way I was able to do this was with the following twig code as the value for the href attribute:

{{ wp_find_one_option_by_name('siteurl').value ~ '/' ~ post.slug }}

This seems a bit verbose for what I think should be a simple {{ post.friendlyUrl }} or some such.

Am I missing something?

When doctrine:generate:entities - Error on TablePrefixSubscriber.php : getClassAnnotations() must be an instance of ReflectionClass

When I run the doctrine:generate:entities command on my projet, I get this error:

PHP Catchable fatal error:  Argument 1 passed to Doctrine\Common\Annotations\AnnotationReader::getClassAnnotations() must be an instance of ReflectionClass, null given, called in .../vendor/kayue/kayue-wordpress-bundle/Kayue/WordpressBundle/Subscriber/TablePrefixSubscriber.php on line 31 and defined in .../vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationReader.php on line 153

I found a way to get around it here:
oroinc/platform#5

by adding this to Subscriber\TablePrefixSubscriber.php:

use Doctrine\Common\Persistence\Mapping\RuntimeReflectionService;
public function loadClassMetadata(LoadClassMetadataEventArgs $args)
    {
        $classMetadata = $args->getClassMetadata();
        $rrs = new RuntimeReflectionService();
        $classMetadata->wakeupReflection($rrs);
[...]

though I honestly do not understand what's going on...

Does anyone else get this issue? Is it project-related? Can this work-around be used in any case and thus be added to this bundle?

Thanks.

Cannot autowire: The class 'Kayue\WordpressBundle\Entity\Post' was not found in the chain configured namespaces App\Entity

Hi, I'm stuck in my Symfony 4.4.1 project.

This is my config:

// config/packages/kayue_wordpress.yaml

kayue_wordpress:
  connection: 'wordpress'
// config/packages/doctrine.yaml

doctrine:
    dbal:
        default_connection: default
        connections:
            default:
                url: '%env(resolve:DATABASE_URL)%'
                charset: utf8mb4
                default_table_options:
                    collate: utf8mb4_unicode_ci
            wordpress:
                url: '%env(resolve:DATABASE_URL_WORDPRESS)%'
                charset: utf8mb4
                default_table_options:
                    collate: utf8mb4_unicode_ci

    orm:
        auto_generate_proxy_classes: true
        default_entity_manager: default
        entity_managers:
            default:
                connection: default
                auto_mapping: true
                naming_strategy: doctrine.orm.naming_strategy.underscore
                mappings:
                    App:
                        is_bundle: false
                        type: annotation
                        dir: '%kernel.project_dir%/src/Entity'
                        prefix: 'App\Entity'
                        alias: App
            wordpress:
                connection: wordpress
                mappings:
                    KayueWordpressBundle:
                        is_bundle: true

Unfortunately I'm unable to get the repo:

<?php

namespace App\Service\WordPress;

use App\Traits\Foreachable;
use Doctrine\ORM\EntityManagerInterface;
use Kayue\WordpressBundle\Entity\Post;

class PostCollection implements \Iterator
{
    use Foreachable;

    protected $postRepository;

    public function __construct(EntityManagerInterface $entityManager)
    {
        $this->postRepository = $entityManager->getRepository(Post::class);
    }
}

I get:

The class 'Kayue\WordpressBundle\Entity\Post' was not found in the chain configured namespaces App\Entity.

I'm pretty sure my repo for WordPress is misconfigured, but I cannot understand how to fix it.

Thanks for you help, merry Christmas!

Using createQueryBuilder with Blog id

Hi Kayue,
I'm using this code to load term by it's parent id

$posts =$this->em->createQueryBuilder()
            ->from('KayueWordpressBundle:Taxonomy', 'tax')
            ->select('tax')
            ->leftJoin('tax.term', 'term')
            ->andWhere('tax.name = :tax')
            ->andWhere('tax.parent=:parent')
            ->setParameter('tax', 'category')
            ->setParameter('parent', $parent_id)
            ->getQuery()->getResult();

Can I using this code to get data from multisite blog? I want to do more work with your bundle, thanks.

Override the User type so I can implement an interface

I need the users loaded by this bundle to implement an interface so I can use them in place of my other users loaded by FOSUserBundle.

I was able to almost do this by making a child bundle to override the Entitiy/User.php file with a new one. I had to just copy-paste the entity from the bundle and add my interface and implement the methods. The problem is, since the Doctrine mapping is already in the annotations in this bundle, I now have two entities that use the same table.

I added resolve_target_entities to my config which seemed to work:

doctrine:
    orm:
        auto_generate_proxy_classes: %kernel.debug%
        default_entity_manager:   default
        entity_managers:
            default:
                connection: default
                mappings:
                    StudyMainBundle: ~
                    FOSUserBundle: ~
            wordpress:
                connection: wordpress
                mappings:
                    KayueWordpressBundle: ~
                    StudyWordPressBundle: ~
        resolve_target_entities:
            Kayue\WordpressBundle\Entity\User: Study\WordPressBundle\Entity\User

The problem is that my unittests/functional tests always load fixtures and Doctrine doesn't like that it finds two entities that map to the table wp_users.

Could you make some change so that users can be overridden? Maybe use the MappedSuperclass pattern that FOSUserBundle does https://symfony.com/doc/1.3.x/bundles/FOSUserBundle/index.html ? If there is some other way I can accomplish this, please let me know.

How to use this an FOSUserBundle for login

How do I use both this and FOSUserBundle for login?

I want to allow admins on my WP site to login to Symfony, but I'm using FOSUserBundle for normal users.

Do I need separate login forms or can I have one form that tries FOSUserBundle and falls back to Wordpress with KayueWordpressBundle?

So far I have this (but only FOSUserBundle works):

security:
    encoders:
        FOS\UserBundle\Model\UserInterface: sha512
        Kayue\WordpressBundle\Entity\User:
            id: kayue_wordpress.security.encoder.phpass

    role_hierarchy:
        ROLE_LIMITED_ADMIN: ROLE_USER
        ROLE_ADMIN_RO:    [ROLE_LIMITED_ADMIN]
        ROLE_ADMIN:       [ROLE_ADMIN_RO]
        ROLE_SUPER_ADMIN: [ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]

    access_decision_manager:
        strategy: unanimous

    providers:
        fos_userbundle:
            id: fos_user.user_provider.username_email
        wordpress:
            entity:
                class: Kayue\WordpressBundle\Entity\User
                property: username
                manager_name: wordpress

    firewalls:
        main:
            pattern: ^/
            form_login:
                provider: fos_userbundle
                csrf_provider: form.csrf_provider
            logout:       true
            anonymous:    true
            switch_user:  true
            kayue_wordpress: ~
        dev:
            pattern:  ^/(_(profiler|wdt)|css|images|js)/
            security: false

    access_control:
        - { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/admin/, role: ROLE_ADMIN_RO }
        - { path: ^/dash/, role: ROLE_USER }
        - { path: ^/apply/, role: ROLE_USER }
        - { path: ^/profile, role: ROLE_NEW_USER }

Get all post by it's term slug

Hi,

Can I get all post by desire term slug( eg:uncategorized ) ?
I'm using Wordpress as backend and Symfony2 to get all data.

Thanks

Incompatibility with doctrine fixtures

It seems that this bundle may have a compatibility issue with doctrine fixtures and migrations in that it causes doctrine to want to modify wordpress tables whenever you generate a schema diff or when you try to load fixtures.

We like that this bundle provides a doctrine-friendly interface to retrieving and displaying blog data, but we need the blog tables to not be effected by doctrine fixtures because they are part of the wordpress application and not the main application. Doctrine fixtures wants to modify foreign keys on wordpress tables and complains that wp_blogs table doesnt exist if you arent using a multi-blog wordpress install.

Are we doing something wrong? Is there a way to solve this via configuration?

Supported Symfony version

Hi,

Thanks for putting this repository online. I'm sure it'll be helpful to many people. Could you tell me if Symfony version 2.2.* is supported?

Thanks,
Anthony

[RFC] Gallery shortcode

In order to transform galery shortcodes I suggest a solution with many improvements:

  • New gallery controller
  • Repository class for Post items

Anything against this suggestion ?

This is a WIP proposal.

securety.yml

Hi,
i have installed KayueWordpressBundle with no errors but I don't understand how set up cross autetication between wp e sf2, my security.yml is like this:
...
providers:
admin:
entity: { class: PromotionclubUserBundle:User}
user:
entity: { class: PromotionclubUserBundle:User}
# Add the WordPress user provider
wordpress:
entity: { class: Kayue\WordpressBundle\Entity\User, property: username }

firewalls:
    login:
        pattern:  ^/wp/secured/login$
        security: false
    secured_area:
        pattern:    ^/wp/secured/
        # Add the WordPress firewall. Allow you to read WordPress's login state in Symfony app.
        kayue_wordpress: ~
        # Optional. Symfony's default form login works for WordPress user too.
        form_login:
             check_path: /wp/secured/login_check
             login_path: /wp/secured/login
             default_target_path: /
        # Optional. Use this to logout.
        logout:
            path:   /wp/secured/logout
            target: /wp/secured/login 
    dev:
        pattern:  ^/(_(profiler|wdt)|css|images|js)/
        security: false

    admin_secured_area:
        pattern:    ^/admin
        anonymous: ~
        context: primary_auth
        form_login:
            login_path: admin_login
            check_path: admin_login_check
            always_use_default_target_path: true
            default_target_path: /admin/home
            csrf_provider: form.csrf_provider
        http_basic:
            realm: "Secured Admin Area"
        logout:
            path: admin_logout
            target: admin_login
            invalidate_session: true

    users_secured_area:
        pattern:    ^/ 

...
If I try to load [url site]/wp/secured/login I have fatal error
My wp installation url in [url site]/forum

Do you explain to me where is the error in my config file?
Many thank's
Best regards

dbpatty

wordpress Authentication

i had integrate my project with fosUserBundle before i use KayueWordpressBundle

my Security.yml file is:

security:
    encoders:
        Symfony\Component\Security\Core\User\User: plaintext
        FOS\UserBundle\Model\UserInterface: sha512
        Kayue\WordpressBundle\Entity\User:
            id: kayue_wordpress.security.encoder.phpass

    role_hierarchy:
        ROLE_SUPER_ADMIN: ROLE_SUPER_ADMIN
        ROLE_CUSTOMER: ROLE_CUSTOMER
        ROLE_SERVICE_PROVIDER: ROLE_SERVICE_PROVIDER

    providers:
        in_memory:
            memory:
                users:
                    user:  { password: userpass, roles: [ 'ROLE_USER' ] }
                    admin: { password: adminpass, roles: [ 'ROLE_ADMIN' ] }      
        fos_userbundle:
            id: fos_user.user_provider.username
        wordpress:
            entity: { class: Kayue\WordpressBundle\Entity\User, property: username }
    firewalls:
        dev:
            pattern:  ^/(_(profiler|wdt)|css|images|js)/
            security: false

        login:
            pattern:  ^/demo/secured/login$
            security: false

        main:
            remember_me:
                key:  "%secret%"
                lifetime: 31536000 
                path:    /
                domain:   ~                                 
            pattern: ^/
            kayue_wordpress: ~
            form_login:
                remember_me: true
                provider: fos_userbundle
                csrf_provider: form.csrf_provider
            logout:
                target: /login
            anonymous:    true

    access_control:
        #- { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY, requires_channel: https }
        - { path: ^/$, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/home/service-provider, role: ROLE_SERVICE_PROVIDER }
        - { path: ^/home/customer, role: ROLE_CUSTOMER }
        - { path: ^/home/admin, role: ROLE_SUPER_ADMIN } 
        - { path: ^/main/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/main/connect, roles: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/main, roles: ROLE_USER }
    acl:
        connection: default

when i try to open Login page , this Exception will happen

FatalErrorException: Error: Call to undefined method Kayue\WordpressBundle\Security\Firewall\WordpressListener::setRememberMeServices() in /var/www/profile_tree/app/cache/dev/appDevDebugProjectContainer.php line 1818 

IS There any way to use KayueWordpressBundle with fosUserBundle

Sharing Session between symfony and wordpress

It's not really an issue, as it is actually something I'm trying to understand.
With this bundle I was able to log in, in the symfony secured area using username/password from my wordpress installation.
Here is my question, is it possible to share the login session between symfony and wordpress using this bundle?
What I mean is, can i login on wordpress, and go to the secured area of symfony and found myself already logged in?

Codex backwards compatibilty in Twig in order to port more functions

Currently the most used class I make use of is the WordpressTwigExtension from the deprecated predecessor of this library. In my opinion this extension worked great because it enabled me to very easily integrate Wordpress in my Symfony application.
https://github.com/kayue/WordpressBundle/blob/master/Extensions/WordpressTwigExtension.php

I see you've removed the magic __call() function from the current WordpressTwigExtension, which took care of handling all known Codex functions in Twig
https://github.com/kayue/KayueWordpressBundle/blob/master/Twig/Extension/WordpressExtension.php

For the sake of backwards compatibility, wouldn't it be a good idea to reintroduce the magic function? Probably the most important reason for not doing this is because then the entire core has to be loaded?

I think it always will be needed to wake up the core, since there are a lot of plugins that add hooks to the functions, and introduce their own functions. Take the WPML internationalization plugin as example, which adds hooks to determine the correct language.

Do you've got another idea how to take care of the hooks, aside of adding the magic __call() again?

Fix 3.x Deprecation warnings before 3.x release

There are a lot of Twig deprecation warnings (in 1.12 for 2.x):

DEPRECATED - Using an instance of "Twig_Filter_Method" for filter "wp_autop" is deprecated. Use Twig_SimpleFilter instead.
DEPRECATED - Using an instance of "Twig_Function_Method" for function "wp_switch_blog" is deprecated. Use Twig_SimpleFunction instead.

Can you update this to use the new Twig functions/filters?

Composer problems with versions

Hello,
I'm trying to use the bundle but with both 1.2@dev and dev-master there is many errors. I notice that in 1.2.0 the Repository directory is missing. Using master the entity_manager conf is not recognized. And more...
Please can you fix with a stable version?

Regards

Attempted to call method "setBlogId" on class "Doctrine\ORM\EntityManager" in vendor/kayue/kayue-wordpress-bundle/Kayue/WordpressBundle/Model/BlogManager.php line 62.

After upgrade to 1.1.1 from 1.1.0 i'm getting this error:

UndefinedMethodException: Attempted to call method "setBlogId" on class "Doctrine\ORM\EntityManager" in /Users/hudson/Documents/Projects/Gpz2/Six3nine/Src/vendor/kayue/kayue-wordpress-bundle/Kayue/WordpressBundle/Model/BlogManager.php line 62.

when trying to do something like this:

/** @var $blogManager \Kayue\WordpressBundle\Model\BlogManager */
$blogManager = $this->get("kayue_wordpress.blog.manager");
$trainerBlog = $blogManager->findBlogById($trainer->getBlogNumber())->getEntityManager();

Now I'm revert to 1.1.0 to avoid this

[Insight] Missing use statement should be avoided

in Twig/Extension/WordpressExtension.php, line 172

The class User resolves to Kayue\WordpressBundle\Twig\Extension\User in this class namespace. This class doesn't seem to exist in the project class map. Did you forget to add a use statement? Or did you forget to prefix this class with a \?

    public function findAllMetasByPost(Post $post)
    {
        return $this->postMetaManager->findAllMetasByPost($post);
    }

    public function findAllMetasByUser(User $user)
    {
        return $this->userMetaManager->findAllMetasByUser($user);
    }

    public function findMetasBy(array $criteria)

Posted from SensioLabsInsight

Missing Service

You have requested a non-existent service "kayue_wordpress". Did you mean one of these: "kayue_wordpress.table_prefix.subscriber", "kayue_wordpress.blog.manager", "kayue_wordpress.shortcode_chain", "kayue_wordpress.shortcode.caption", "kayue_wordpress.shortcode.gallery", "kayue_wordpress.option.manager", "kayue_wordpress.post.manager", "kayue_wordpress.post_meta.manager", "kayue_wordpress.attachment.manager", "kayue_wordpress.term.manager", "kayue_wordpress.user_meta.manager", "kayue_wordpress.comment.manager", "kayue_wordpress.twig.wordpress"?

Can you help please?
Best regards

A Token was not found in the SecurityContext.

I am using Symfony 2.3.24 and the 1.2.0 version of this bundle.

I installed and configured the bundle and the firewall, but when I try to enter the secured area, the following exception is thrown:

A Token was not found in the SecurityContext.
500 Internal Server Error - AuthenticationCredentialsNotFoundException

This is my security.yml file, I want all pages to be secured:

security:
    encoders:
        Kayue\WordpressBundle\Entity\User:
            id: kayue_wordpress.security.encoder.phpass

    role_hierarchy:
        ROLE_ADMIN:       ROLE_USER
        ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]

    providers:
        wordpress:
            entity: { class: Kayue\WordpressBundle\Entity\User, property: username }

    firewalls:
        dev:
            pattern:  ^/(_(profiler|wdt)|css|images|js)/
            security: false

        secured_area:
            pattern:    ^/
            kayue_wordpress: ~

    access_control:
        - { path: ^/, roles: ROLE_ADMIN }

Cannot persist Comment or Post entities

Hi,

if i try to persist a post or comment entity,
i get this error from doctrine:
ContextErrorException: Notice: Undefined index: 000000000895bb6c00007ff6bd269d51 in /var/www/FlywersApi/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php line 2860

I think that this is because i cannot synchronize the db schema, indeed, running "php app/console doctrine:schema:update" i get:

[Doctrine\DBAL\DBALException]
An exception occurred while executing 'ALTER TABLE wp_postmeta ADD CONSTRAINT FK_41C0A2764B89032C FOREIGN KEY (post_id) REFERENCES wp_posts (ID)':

SQLSTATE[HY000]: General error: 1005 Can't create table 'flywers.#sql-4a3d_13adb' (errno: 150)

How could i solve this problem? i would just need to persist a new comment

Post Thumbnail

How should one get post thumbnail in twig?

    {% set img = wp_find_featured_image(post) %}
    {{ img.slug }}

does not give me the image url.

SF2 interaction with "real" wordpress blog

Hi,

I don't know if this is only a bonus, but:

  • I installed wordpress in my test.loc domain, and symfony in sub.test.loc
  • I've set logged_in_key and logged_in_salt in config.yml to same as in wp-config.php

And:

  • When I login/logout on Acme Demo Bundle it works on Symfony side
  • when I'm loging/logout via wordpres (wp-login.php) then I'm logged in/out in both (WP and SF2)
  • when I'm logged in via wp-login.php I can't logout on symfony side (Im still logged in)
  • when I'm logged in via Symfony I'm not automaticly logged in "real" Wordpress

So ... it's almost SSO ... from Wordpress on main domain I can login/logout from both applications, but from Symfony (Your bundle) I can only login/logout from SF2 (on WP I'm still logged off).
Is there a way to make Your bundle both-sides SSO?

Update symfony db

Hello,
I am using the KayueWordpressBundle and it works very well! (i can retrieve data about posts, blogs, users, ... correctly).

The problem is that i would like to add a new table to the database, so i generated a new entity and run the command:

php app/console doctrine:schema:update --force

Could you help me :) ?

Thank you!!

I got the following error, so actually i can't update the db (i am using wordpress 3.8.1 and the last realease of the kayueWordpressBundle).

[Doctrine\DBAL\DBALException]
An exception occurred while executing 'ALTER TABLE wp_postmeta ADD CONSTRAINT FK_41C0A2764B89032C FOREIGN KEY (post_id) REFERENCES wp_posts (ID)':

SQLSTATE[HY000]: General error: 1005 Can't create table 'flywers.#sql-456_108' (errno: 150)

[PDOException]
SQLSTATE[HY000]: General error: 1005 Can't create table 'flywers.#sql-456_108' (errno: 150)

Different database for WP?

Hi, is it possible to use a database for Symfony2 application and a separated database for WP?
Many thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.