Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] How to hook into an event in Console SiteBuilder command #135

Closed
cmosguy opened this issue Aug 6, 2017 · 3 comments
Closed

Comments

@cmosguy
Copy link

cmosguy commented Aug 6, 2017

@damiani so I am trying to build an Algolia indexer that crawls through the markdown files that we use during the build process. I am trying to understand how to hook into the SiteBuilder command. I was reading this: http://symfony.com/doc/current/components/console/events.html but I could not figure out how to pull the EventDispatcher without pulling in the entire symfony/somfony package.

Is there an easy way to add an event listener that listens to ConsoleEvents::TERMINATE so that when the build process is completed, I can kick off another class that does the work I need to do. For example, I am going to go through the data from the markdown content in my new class that I want to make.

I was trying to figure out how to get the Illumunate\Event to work, but I am struggling to figure out how to build the listener for this when the console event is fired and "TERMINATES".

Thanks!
Adam

@damiani
Copy link
Contributor

damiani commented Aug 6, 2017

Presumably you would only want to run this when building for production, right? So we'd need to either hook it into the config files (i.e. via a middleware-type function that runs before or after the site files are processed, but conditionally based on environment) or, alternatively, if you went the Symfony-events route, you could check which options were provided to the build command.

There's no way I can think of doing this out-of-the-box, but I'm definitely open to exploring options for adding support for this. I just want to get a sense of some of the various use cases we can target, so we build something that's flexible and easy for users (such as those described in #120).

@cmosguy
Copy link
Author

cmosguy commented Aug 7, 2017

Thanks @damiani,

I created a pull request here: #136

Thanks to the great @mattstauffer for inspiring us on his Containers education from his talks and books. We can simply use the existing container in Jigsaw to make any Event/Listener we want. Now, we just need to figure out how to get this more streamlined to add listeners and then update the Docs if you accept these ideas.

BTW, your middleware ideas are good. Also, yes, I only want to build the index only for production.

Cheers!

@damiani
Copy link
Contributor

damiani commented Mar 2, 2018

Let's move any further discussion of this feature to the PR #136

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants